Write a function declaration for a function called grader that takes a numeric score and returns a letter grade. Grade has one argument of type integer. Use the rule that 90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C and less than 70 is an F.
def getLetterGrade(score):
score = round(score)
grades = [(90, 'A'), (80, 'B'), (70, 'C'), (60, 'D'), (0, 'F')]
for i in range(len(grades)):
if score >= grades[i][0]:
return grades[i][1]
Comments
Leave a comment