Good place to stop if you're short on time — step 3 picks up here.
Lesson idea Tap to fold
Without scrolling back — what does shot_duration == target_duration actually produce?
Show the answer
Answer. A boolean — True if they're equal, False if they're not. The == sign checks equality; it doesn't assign anything.
And from further back — in a three-item list, which number in square brackets gets you the last item?
Show the answer
Answer. [2]. Counting starts at zero, so the third item is two steps in.
if is a fork in the edit
Yesterday a boolean just sat in a box. Today it decides which code actually runs — the way a fork in the timeline sends the edit down one path or another, never both.
# Set up the values for this step
frame_count = 240
# Choose the matching result
if frame_count == 240:
print("Duration OK")
else:
print("Duration mismatch")
Python checks the boolean right after if. True, and the indented lines under if run. False, and it skips straight to the indented lines under else. Exactly one of the two blocks runs — never both, never neither.
The indent decides which block a line belongs to — same rule as a loop. Everything indented under if is "what happens when true." Everything indented under else is "what happens otherwise." else carries no condition of its own — it doesn't need one, because it's already everything the if didn't catch.
You already learned to read indentation as "inside the loop" back on Day 3. Today it means the same thing in a different shape: "inside this branch." One rule, two uses.
That is the whole idea for today. A boolean decides, the indent marks the two paths, and exactly one of them runs.
Predict, explain, then test
These three short checks are self-reviewed, not a quiz score. The code checks below rerun your rule on changed inputs and boundaries. They keep your named input facts and check your rule, not one required quote style.
Predict the other path
If frame_count is 239 and the condition is frame_count == 240, which path runs?
Compare your answer · self-reviewed
The condition is False, so else runs. The if branch is skipped, rather than both messages printing.
Read the block
Which lines belong to an if or else block?
Compare your answer · self-reviewed
Their indentation identifies the block. The colon introduces it; indentation determines which statements execute together.
Debug a fixed answer
Why is print("Duration OK") not a replacement for the branch?
Compare your answer · self-reviewed
It never reacts to a mismatch. A useful decision must respond to new measured values.
Choose an exercise to load its prompt.
Today's idea in two other voices, if you want one. Not required — the exercises above are the actual lesson.
- Conditional Statements in Python — article, Real Python
- Python Tutorial for Beginners 6: Conditionals and Booleans — video, Corey Schafer
Loading exercises…
Noted on your route map, with the step you were on. Nothing is lost by parking it — the next review day will bring this idea back, and the flag tells the course where to slow down.
The tutor mounts here when JavaScript is available. The lesson above stays readable without it.