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.
Change age and make it print adult only when age is 18 or more.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? These paid resources pick up where this lesson leaves off.
Project-based Python Foundations video courses — the perfect paid next step after these free lessons.
Browse on Udemy →Hand-picked Python Foundations books to master the fundamentals offline.
See on Amazon →Some links on this page are affiliate links: we may earn a commission at no extra cost to you. We only recommend tools we believe are genuinely useful.