easy +8 pts

Grade from Score

Convert a numeric score into a letter grade with clear thresholds.

Write a function `grade_from_score(score)` that takes an integer score between 0 and 100 (inclusive) and returns the corresponding letter grade as a string, according to the following scale: - 90 to 100 → "A" - 80 to 89 → "B" - 70 to 79 → "C" - 60 to 69 → "D" - 0 to 59 → "F" You may assume the input is always an integer within the given range. The function should return exactly one of the strings "A", "B", "C", "D", or "F".

Constraints

- Input `score` is an integer satisfying 0 <= score <= 100. - The function should return a string.

Example

>>> grade_from_score(95)
'A'
>>> grade_from_score(84)
'B'
>>> grade_from_score(60)
'D'
>>> grade_from_score(0)
'F'
8 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use if/elif/else to check ranges in order.
Start with the highest grade range and work downward.
Remember that the upper bound of each range is inclusive (e.g., 89 is a B).
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.