Start learning free

LESSON 172 OF 410 · PROJECTS: EVERYDAY PROGRAMS

Report Card V3 - Letter Grade in Python

Practice

Use if/elif/else to turn a numeric score into a letter grade.

You start with:

score = 85

Build:

Grade: B

Rules:

  • score >= 90 is "A"; 80-89 is "B"; 70-79 is "C"; 60-69 is "D"; below 60 is "F".
  • The boundaries count: a score of exactly 90 is an A, exactly 80 a B, exactly 70 a C, exactly 60 a D, and 59 is an F.
  • Store the result in a variable named grade. The checker prints "Grade: " followed by its value for you, so do not print anything yourself.

Use a chain: if score >= 90: ... elif score >= 80: ... else: ....

score = 85

if score >= 90:
    grade = "A"
elif score >= 80:
    grade = "B"
elif score >= 70:
    grade = "C"
elif score >= 60:
    grade = "D"
else:
    grade = "F"

STEP 1 OF 5
    Ctrl + Enter to check

    Report Card V3 in Python

    Keep going with PythonAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free