Predict Python if/elif/else Output
Predict OutputBeginner
Question
What does this Python code print?
Code
n = 0
if n > 0:
print("positive")
elif n < 0:
print("negative")
else:
print("zero")
Hint
0 is neither greater than 0 nor less than 0.
Explanation
n is 0. The first condition n > 0 is false. The second condition n < 0 is also false. So the else branch runs and prints: zero
Related Resources
Related Lessons
- Conditions and Loops
Learn how Python if/elif/else conditions work.
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.