In this exercise, I did my code differently by just checking if the gpa and returning the grade.
But when I saw how system did it, i was confused. Why did it use "grade = “F” for? and can you also explain at then end what is return grade doing?
So we print the letter grade according to the score. This is how I did it, which is different.
def grade_converter(grade):
if grade >= 90:
return "A"
elif grade >= 80 and grade <= 89:
return "B"
elif grade >= 70 and grade <= 79:
return "C"
elif grade >= 65 and grade <= 69:
return "D"
else:
return "F"
# This should print an "A"
print(grade_converter(92))
# This should print a "C"
print(grade_converter(70))
# This should print an "F"
print(grade_converter(61))
So there could be a singular return statement, rather than multiple. Some would have it that way for greater clarity. There are discussions relating to multiple returns from a function if you are willing to dig around the SERPs.