Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read a score from 0 to 100 and print its letter grade.
90+ is A, 80–89 is B, 70–79 is C, 60–69 is D, and anything below 60 is F.
Input. One line: an integer from 0 to 100.
Output. A single letter: A, B, C, D, or F.
Constraints
- 0 ≤ score ≤ 100
Examples
Input
95
Output
A
Input
82
Output
B
Input
59
Output
F
Hint
- Use an if / elif chain, checking the highest band first.
- Once you check score >= 90, the next elif only needs score >= 80 — the earlier case already handled 90+.
Show correct code
Peek only after you have tried. You can still Check your own version.
score = int(input())
if score >= 90:
print("A")
elif score >= 80:
print("B")
elif score >= 70:
print("C")
elif score >= 60:
print("D")
else:
print("F")
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.