To get started, a filter could ju applicant's grades and accept meet a certain average. 85 is a to start.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
In python
First, your co-worker suggests, “Let’s just take students who have a B average or better in all of their courses.”

To get started, a filter could just take the average of an applicant’s grades and accept only those students who meet a certain average. 85 is a middle B, so let’s try that to start.

Begin the function with the header:
```python
def filter_average(cand):
```

This function should take as input a single candidate (list of grades), and return True if the candidate’s average grade across all classes (not just Computer Science) is 85 or higher, or False otherwise. **Note that index 6 contains this value - you don’t need to compute an average.** This will help determine whether the candidate should be interviewed or not.

Test your function to make sure it works for the various candidates. To do this, you should write test cases using the candidate lists provided above. Two have been given to you below - copy these to the bottom of your Python file and provide at least two more tests, along with their expected outputs. Determine the expected output in advance by looking at the list manually, don’t just run the test and write down whatever was output as the expected output.

```python
if __name__ == '__main__':
    print(filter_average(candidate9))
    #Should output False
    print(filter_average(candidate5))
    #Should output True
    print(filter_average(candidate2))
    #Should output True
```
Transcribed Image Text:First, your co-worker suggests, “Let’s just take students who have a B average or better in all of their courses.” To get started, a filter could just take the average of an applicant’s grades and accept only those students who meet a certain average. 85 is a middle B, so let’s try that to start. Begin the function with the header: ```python def filter_average(cand): ``` This function should take as input a single candidate (list of grades), and return True if the candidate’s average grade across all classes (not just Computer Science) is 85 or higher, or False otherwise. **Note that index 6 contains this value - you don’t need to compute an average.** This will help determine whether the candidate should be interviewed or not. Test your function to make sure it works for the various candidates. To do this, you should write test cases using the candidate lists provided above. Two have been given to you below - copy these to the bottom of your Python file and provide at least two more tests, along with their expected outputs. Determine the expected output in advance by looking at the list manually, don’t just run the test and write down whatever was output as the expected output. ```python if __name__ == '__main__': print(filter_average(candidate9)) #Should output False print(filter_average(candidate5)) #Should output True print(filter_average(candidate2)) #Should output True ```
**Candidate Scores for Code Testing**

Below are ten sets of candidate scores. You can use some or all of these examples to test your code:

- **candidate1** = [95, 93, 50, 91, 98, 90, 82]
- **candidate2** = [65, 75, 85, 95, 100, 85]
- **candidate3** = [100, 100, 95, 85, 75, 65, 80]
- **candidate4** = [98, 70, 55, 61, 98, 90, 90]
- **candidate5** = [100, 95, 55, 61, 75, 95, 90]
- **candidate6** = [95, 90, 98, 88, 93, 95, 94]
- **candidate7** = [90, 80, 80, 100, 70, 75, 90]
- **candidate8** = [80, 83, 79, 83, 77, 77, 82]
- **candidate9** = [90, 100, 100, 98, 100, 99, 55]
- **candidate10** = [77, 82, 92, 100, 95, 92, 70]

Feel free to use these data points to assess the functionality and accuracy of your programming solutions.
Transcribed Image Text:**Candidate Scores for Code Testing** Below are ten sets of candidate scores. You can use some or all of these examples to test your code: - **candidate1** = [95, 93, 50, 91, 98, 90, 82] - **candidate2** = [65, 75, 85, 95, 100, 85] - **candidate3** = [100, 100, 95, 85, 75, 65, 80] - **candidate4** = [98, 70, 55, 61, 98, 90, 90] - **candidate5** = [100, 95, 55, 61, 75, 95, 90] - **candidate6** = [95, 90, 98, 88, 93, 95, 94] - **candidate7** = [90, 80, 80, 100, 70, 75, 90] - **candidate8** = [80, 83, 79, 83, 77, 77, 82] - **candidate9** = [90, 100, 100, 98, 100, 99, 55] - **candidate10** = [77, 82, 92, 100, 95, 92, 70] Feel free to use these data points to assess the functionality and accuracy of your programming solutions.
Expert Solution
Step 1 Source Code

def filter_average(cand):
    if cand[6] >= 85:
        return True
    else:
        return False

if __name__== '__main__':
    candidate9 = [90, 100, 100, 98, 100, 99, 55]
    candidate5 = [100, 95, 55, 61, 75, 95, 90]
    candidate2 = [65, 75, 85, 95, 100, 100, 85]
    print (filter_average(candidate9))
    print (filter_average(candidate5))
    print (filter_average (candidate2))

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Database connectivity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education