) Define a function, when input is a list of scores, return its corresponding list of grades (You can use functions defined in the previous sub problems). i.e. the 1st grade (in the list of grade) is the grade of 1st score (in the list of score), the 2nd grade (in the list of grade) is the grade of 2nd score (in the list of scores)... For example, when input is [100, 20, 75, 81], your function should return a list of grade ["A", "F", "C", "B"]. (you can use any function you defined in previous sub problems)

Respuesta :

Answer:

def letter_grade(grades):

   letters = []

   for grade in grades:

       if grade >= 90 and grade <= 100:

           grade = 'A'

       elif grade >=80 and grade <= 89:

           grade = 'B'

       elif grade >=70 and grade <= 79:

           grade = 'C'

       elif grade >=60 and grade <= 69:

           grade = 'D'

       else:

           grade = 'F'

       

       letters.append(grade)

   return letters

lst = [100, 20, 75, 81]

print(letter_grade(lst))

Explanation:

Create a function called letter_grade that takes one parameter, grades

Create an empty list, letters, to hold the letter grades

Initialize a for loop iterates through the grades. Check each grade, find its convenient letter and put it in the letters.

When the loop is done, return the letters.

Call the function with given list and print the result