Daily Python
Day 4Python~30 min
Decisions with if/else
Compare values and branch your code
Track progress0/15 days
What you'll learn
ifelifelseandorcomparison operators
- Write if / elif / else blocks
- Combine conditions with and and or
- Compare two numbers and explain the result
- Detect when a number is zero
Lesson & examples
Read the code, then the explanation — try changing values before the project.
if / elif / else
number = 4
if number > 5:
print("Greater than 5.")
elif number == 5:
print("Equal to 5.")
else:
print("Less than 5.")Logical operators
a, b = 2, 20
if a > 5 or b < 15:
print("At least one condition is true")