Define a function below called process_grades. The function takes one argument: a list of integers. Each integer in the list corresponds to a student's grade in a class. Complete the function such that it returns a new list where the integer grades are replaced by letter grades. For this question, use a standard grading scale without +/- grade, as follows A: 90-100 B: 80-89 C: 70-79 D: 60-69 F: < 60 For example, given the list [90, 85, 85, 72], the function should return ['A','B','B','C'].

Respuesta :

Limosa

Answer:

Following are the code in the Python Programming Language.

#define function

def process_grades(std_grades):

 result = []   #list type variable

 for grades in std_grades:   #set for loop

   if 90<=grades<=100:    #set if statement

     lettersGrade = 'A'   #variable initialization

   elif 80<=grades<=89:   #set elif statement

     lettersGrade = 'B'   #variable initialization

   elif 70<=grades<=79:   #set elif statement

     lettersGrade = 'C'    #variable initialization

   elif 60<=grades<=69:     #set elif statement

     lettersGrade = 'D'    #variable initialization

   else:    

     lettersGrade = 'F'    #variable initialization

   result.append(lettersGrade)     #append the value of lettersGrade in result

 return result      #print the value of the variable result

print(process_grades([90, 85, 85, 72]))   #call the function

Output:

['A', 'B', 'B', 'C']

Explanation:

Here, we define the function "process_grades" and pass an argument in the parameter list is "std_grades" in which we pass the grades of the students.

Then, we set the list data type variable "result" i9n which we store the grades of the students.

Then, we set the for loop and pass the condition.

Then, we set the "if-elif" statement and pass the conditions as given in the question.

Then, we append the value of the variable "lettersGrade" in the variable "result".

Finally, we call then function.