Caffeinated Coder
Book an appointment
Lesson 05 · Basics

Conditionals: if, elif and else

Programs make decisions with if. A condition is a yes-or-no question, such as temp >= 25, and its answer is a bool: True or False. Step through wear.py, which asks for the temperature and picks a T-shirt, a jumper or a coat, and watch which lines run and which are skipped. Run it twice with different answers, then meet the slip every beginner makes: = instead of ==.

12 min10 steps5 questionsBeginner
Fig 5 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.