Student Grade
Programming Basics · Python
TASK
Problem
Given score 0..100, print `5` for 90..100, `4` for 75..89, `3` for 60..74, and `2` otherwise.
EXAMPLE
Example
83
4
LIMITS
Constraints
0 ≤ score ≤ 100
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `int()` converts a numeric string into an integer. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** An `if` statement chooses a program branch from a Boolean condition. Comparisons produce `True` or `False`, and `elif` lets you test several mutually exclusive cases in order. The expression `5` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Check thresholds from highest to lowest.']
ANSWER
Solution
+
s = int(input())
if s >= 90:
print(5)
elif s >= 75:
print(4)
elif s >= 60:
print(3)
else:
print(2)