25 XP

10. Letter grade

Beginner conditions

Write a function grade(score) that takes a test score from 0 to 100 and returns its letter grade, as a string of one capital letter:

Score Grade
90 to 100 "A"
80 to 89 "B"
70 to 79 "C"
60 to 69 "D"
0 to 59 "F"

Both ends of each range count: exactly 90 is an "A", exactly 80 is a "B", and so on. There is no "E".

Example 1

Inputscore = 95
Output"A"
Explanation95 is in the range 90 to 100.

Example 2

Inputscore = 72
Output"C"
Explanation72 is in the range 70 to 79.

Example 3

Inputscore = 60
Output"D"
Explanation60 is the lowest score that gets a D.

Constraints

  • score is a whole number from 0 to 100.

Submit also runs 7 more tests you can't see.

Practises If / Elif / Else (lesson 8).

Code
def grade(score):
    """Turn a score from 0 to 100 into a letter grade.

    score: int, from 0 to 100
    Returns: str, "A", "B", "C", "D" or "F"
    """
    # Write your code here
    pass