In: Computer Science
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program should display a letter grade for each score and the average test score.
Hint:
Declare local variables under main() program
Prompts the user to enter 5 test scores
Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg
Define a function to determine the letter grade: this should accept a test score as argument and return a letter grade based on the following grading scale.
Score Letter Grades
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F
def calc_average(n1,n2,n3,n4,n5): return (n1+n2+n3+n4+n5)/5 def determine_grade(score): if score < 60: letter = 'F' elif score < 70: letter = 'D' elif score < 80: letter = 'C' elif score < 90: letter = 'B' else: letter = 'A' return letter def main(): n1 = eval(input("Enter test score1: ")) n2 = eval(input("Enter test score2: ")) n3 = eval(input("Enter test score3: ")) n4 = eval(input("Enter test score4: ")) n5 = eval(input("Enter test score5: ")) print("\nScore\tLetterGrade") print("------------------------") print(n1,"\t\t",determine_grade(n1)) print(n2, "\t\t", determine_grade(n2)) print(n3, "\t\t", determine_grade(n3)) print(n4, "\t\t", determine_grade(n4)) print(n5, "\t\t", determine_grade(n5)) avg = calc_average(n1,n2,n3,n4,n5) print("\nAverage test score =",avg) main()