Python bootcamp · Lab 05

Letter grade

easyIf Else10 minLesson: If Else

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

Example 1
Input
95
Output
A
Example 2
Input
82
Output
B
Example 3 — The boundary matters: 59 fails, 60 passes.
Input
59
Output
F
Hint
  1. Use an if / elif chain, checking the highest band first.
  2. 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.