Question

Write a function, grade(score), which is given score, and it returns a letter grade — the...

  • Write a function, grade(score), which is given score, and it returns a letter grade — the grade for that mark — according to this scheme:
    • A: >= 90
    • B: [80, 90)
    • C: [70, 80)
    • D: [60, 70)
    • F: < 60
  • The square and round brackets denote closed and open intervals. A closed interval includes the number, and an open interval excludes it. So 79.99999 gets grade C, but 80 gets grade B.
  • Define the main function as follows:
    • In main, your function, grade, should be called. Use a list of scores, [87, 92, 100, 54, 72, 84, 81, 74]. The list should be used for iterating a for loop (i.e. for i in scores:). Using the return value of the grade function, print the letter grade for each score.
  • You have to make sure your main() function in your_lastname_17_1.py should not be called (i.e. run) when your_lastname_17_1 is imported from other Python files.
  • Output
    • 87 has a letter grade, B
      92 has a letter grade, A
      100 has a letter grade, A
      54 has a letter grade, F
      72 has a letter grade, C
      84 has a letter grade, B
      81 has a letter grade, B
      74 has a letter grade, C

Homework Answers

Answer #1

Source Code:

def grade(score):
grade=''
if(score>=90):
grade='A'
elif(score>=80 and score<90):
grade='B'
elif(score>=70 and score<80):
grade='C'
elif(score>=60 and score<70):
grade='D'
elif(score<60):
grade='E'

return grade

scores=[87,92,100,54,72,84,81,74]
for i in scores:
print(i,"has a letter grade")

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Student Grades Student Test Grade 1 76 62 2 84 90 3 79 68 4 88...
Student Grades Student Test Grade 1 76 62 2 84 90 3 79 68 4 88 84 5 76 58 6 66 79 7 75 73 8 94 93 9 66 65 10 92 86 11 80 53 12 87 83 13 86 49 14 63 72 15 92 87 16 75 89 17 69 81 18 92 94 19 79 78 20 60 71 21 68 84 22 71 74 23 61 74 24 68 54 25 76 97...
Machine Problem 3 - Linked List C++ For this assignment you will write a program that...
Machine Problem 3 - Linked List C++ For this assignment you will write a program that inserts 20 random integers from 0 to 100 in order in a linked list object. The program will create another linked list, but with 15 random integers from 0 – 100 in order. The program then will merge those two ordered linked list into a single ordered list. The function merge should receive references to each of the list objects to be merged and...
Mid Score Final Score 80 78 87 85 72 81 69 54 86 70 83 73...
Mid Score Final Score 80 78 87 85 72 81 69 54 86 70 83 73 78 89 75 84 74 86 75 79 84 75 73 63 74 72 73 69 80 86 75 78 72 75 77 68 76 77 66 78 74 77 71 73 85 79 74 74 76 79 76 73 84 72 77 81 78 86 86 76 81 83 78 83 85 86 73 71 83 83 83 79 72 68 83 90...
Below represent scores on an exam, each entry one score for one student 40 99 59...
Below represent scores on an exam, each entry one score for one student 40 99 59 98 63 63 64 65 67 35 67 67 68 70 71 71 71 46 72 72 60 73 74 74 74 75 97 75 62 76 76 76 76 76 77 57 77 98 77 63 78 78 78 79 79 80 80 80 80 80 81 81 92 81 93 82 82 83 83 83 83 83 83 83 84 84 84...
Write a program that keeps reading a test score until a -1 is entered. The program...
Write a program that keeps reading a test score until a -1 is entered. The program will output the letter grade according to the table below: Score Grade 90-100.   A 80-89.   B 70-79.   C 60-69.   D < 60.   F For example: Enter a Score (-1 to Exit): 92 The Letter grade for that score is A. Enter a Score (-1 to Exit): -1
Suppose the previous mean exam score was 70. We would like to know whether or not...
Suppose the previous mean exam score was 70. We would like to know whether or not the mean score has increased. Answer the following question using any approximate method by stating the necessary assumptions. The data are here: 75 70 88 80 80 66 65 68 85 80 78 72 69 75 86 96 77 81 76 80 66 65 78 87 88 75 85 84 66 78 76 74 85 64 76 75 76 74 81 76 (a) State...
Write a Java program to display a letter grade based on an actual grade. A =...
Write a Java program to display a letter grade based on an actual grade. A = 90-100 B = 80-89 C = 70-79 D = 60-69 F = less than 60 The program needs to do the following: 1. Create a short integer to store a grade. (See Week 3 - Things to Know - Java Data Types ) 2. Prompt for a grade ( 0-100). 3. Based on the grade given, use IF statements to display the letter grade...
please answer ALL the question 1--The diastolic blood pressure (in mm Hg) of 84 patients with...
please answer ALL the question 1--The diastolic blood pressure (in mm Hg) of 84 patients with hypertension was: 88 98 78 84 77 81 90 82 75 72 92 85 92 77 84 77 82 100 92 88 74 80 95 90 87 80 83 77 86 80 88 90 79 82 93 100 80 85 96 85 90 84 82 95 88 97 80 88 94 92 88 96 90 103 88 86 84 90 98 88 86 95...
Write a Java program to display a letter grade based on an actual grade. USING ECLIPSE...
Write a Java program to display a letter grade based on an actual grade. USING ECLIPSE IDE A = 90-100 B = 80-89 C = 70-79 D = 60-69 F = less than 60 The program needs to do the following: 1. Create a short integer to store a grade. (See Week 3 - Things to Know - Java Data Types ) 2. Prompt for a grade ( 0-100). 3. Based on the grade given, use IF statements to display...
The following scores represent a sample of final examination grades for a statistics course 23 60...
The following scores represent a sample of final examination grades for a statistics course 23 60 98 32 57 74 52 70 82 69 74 63 80 62 80 77 81 95 41 65 92 85 85 61 36 79 55 76 52 10 64 75 78 25 80 48 83 64 88 82 81 67 41 71 67 54 34 72 74 43 60 78 84 89 76 84 17 90 15 79 a) Provide a frequency polygon with...