Conditionals
Every program you've written so far runs the exact same way every time. Conditionals change that — your code can finally make decisions, which means Zara's story can actually branch.
What You'll Learn
if— runs a block of code only when a condition isTrueelif/else— more conditions to check, then a catch-all; Python runs the firstTruebranch and skips the restand/or/not— combine conditions (both must be true / at least one must be true / flip a bool)
= assigns a value; == compares two values. Mixing them up in a condition (if health = 100:) is actually a SyntaxError in Python — it won't run at all, which is a fast, loud signal once you know what that error means.
Today's Activity
Today's practice happens inside the notebook below — work through it top to bottom:
- A worked example, fully written out
- Two guided practices — change a few values, then fill in some blanks
- Two independent practices — write your own from scratch, different scenario each time
- An optional stretch, if you want to go further
- One check-your-understanding question to close
Download the notebook, save it into your 1_foundations folder in your cloned repo, and open it in VS Code. Commit once you've saved it, then commit again when you're done for the day.
New to notebooks? See Using Jupyter Notebooks first.
What's Next
Coming up: Project 1A — Character & First Choice, your first checkpoint. You'll use exactly what 1.1–1.4 taught you to create a character and write one branching decision.