← Python Foundations
4 / 27
Lesson 4 — if / else
Making decisions
if runs a block only when a condition is true; else covers every other case. A condition is any expression that is True or False, like age >= 18.
Why it matters: decisions are how programs react differently to different data instead of always doing the same thing.
Watch out: in Python the indented spaces under if and else are not decoration — they define which lines belong to each branch.
Want it another way?
Task
Set age to 15 and run it — the program should print: minor. (>= means "greater than or equal to".)
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.