Start free

Beginner · Conditions · 58 of 264

Grade from a score

Turn a test score into a grade: 90 or more is A, 80 or more is B, 70 or more is C, 60 or more is D, anything lower is F.

Input: a score from 0 to 100. Output: the grade letter.

Examples

Input
95
Output
A
Input
80
Output
B
Input
79
Output
C
Input
60
Output
D

2 more tests check other inputs when you press Check.

Stuck? The idea behind conditions

An if statement runs its indented lines only when the condition is true; elif tries another condition; else catches everything left.

Compare with == (equal), != (not equal), <, <=, >, >=, and join conditions with and, or, not.

n = int(input())
if n > 0:
    print("positive")
elif n < 0:
    print("negative")
else:
    print("zero")

Watch for: = gives a value, == compares. And the order of elif matters: the first true one wins, so test the narrow case first.

All the conditions exercises
Your code
Opening the code editor…
Python 3.14 in your browser
Output
Run shows what your program prints. Check tests it on every example and the hidden tests.

More conditions exercises