Predict Nested if/else
Predict Output Medium
Question
What does this code print?
Code
score = 75
if score >= 90:
grade = "A"
elif score >= 80:
grade = "B"
elif score >= 70:
grade = "C"
else:
grade = "F"
print(grade)
Hint
75 is >= 70 but not >= 80.
Explanation
score is 75. 75 >= 90 is false. 75 >= 80 is false. 75 >= 70 is true, so grade = 'C'. The elif chain stops at the first true condition. Output: C
Related Resources
Related Lessons
- Conditions and Loops
if/elif/else.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.