Branches with if / elif / else
14-minute lesson · module-selection-03
You are previewing this course as a guest
Read anything and run any exercise you like. It all runs in your own browser, so nothing here is saved: no XP, no progress, and the AI tutor needs an account. Sign in and your work starts counting.
Branches with if / elif / else
14-minute lesson · module-selection-03
- Write `if`, `elif`, and `else` branches with correct indentation.
- Order branches so the first matching condition is intentional.
- Recognize that only one branch in an if/elif/else chain runs.
Source attribution
Status: adapted
How to Think Like a Computer Scientist: Interactive Edition — source · Selection / The if-elif-else statement
Adaptation notes. Reading rewritten in our voice. Coding exercise (FizzBuzz subset) authored specifically for PyTutor AI.
License notes. Verify chapter-level license metadata on Runestone before copying any text verbatim. This lesson contains no verbatim quotations.