Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following functions as part of the program:

calc_average: This function should accept five test scores as arguments and return the average of the scores.

determine_grade: This function should accept a test score as an argument and return a letter grade for the score based on the following grading scale.

Score Letter grade
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F

Respuesta :

Answer:

def calc_average(s1, s2, s3, s4, s5):

   return (s1 + s2 + s3 + s4 + s5) / 5

def determine_grade(s):

   if 90 <= s <= 100:

       return "A"

   elif 80 <= s <= 89:

       return "B"

   elif 70 <= s <= 79:

       return "C"

   elif 60 <= s <= 69:

       return "D"

   else:

       return "F"

scores = []

for i in range(5):

   scores.append(int(input("Enter a test score: ")))

   print(determine_grade(scores[i]))

print(str(calc_average(scores[0], scores[1], scores[2], scores[3], scores[4])))

Explanation:

Create a function called calc_average that takes 4 test scores, calculates their average, and returns the average

Create a function called determine_grade that takes a test score, returns the grade depending on the grading scale

Create an empty lists that will hold the test scores

Create a for loop to get test scores from the user. After getting a score, call the determine_grade function to determine the grade of the score

When the loop is done, call the calc_average function to calculate the average of the given test scores