Good place to stop if you're short on time — step 3 picks up here.
Lesson idea Tap to fold
Without scrolling back — when Day 5's broken code referred to a variable that was never created, what did Python tell you?
Show the answer
Answer. A NameError — Python names the variable it couldn't find. That's exactly what broke the trace-and-repair exercise until you fixed the typo.
A boolean is a yes/no box
Every idea so far has stored something — a name, a number, a list. Today's box only ever holds one of two values: True or False. Nothing else fits in it.
You don't usually write True or False yourself. You get one back by asking Python a question — a comparison:
# Two numbers to compare
shot_duration = 240
target_duration = 300
# Each comparison answers True or False
print(shot_duration == target_duration)
print(shot_duration < target_duration)
== asks "are these equal?" and < asks "is the left one smaller?" Each one hands back a boolean — the answer to its question, nothing more.
== is not =. One equals sign puts a value in a box. Two equals signs ask whether two things match. They sit one key apart and do opposite jobs — assign versus ask.
This is the single most common typo in this exact chapter, for everyone. Day 1 already told you to read = as "put this in the box." Today's rule locks it in: if you're asking a question, you need the second =. Python will usually complain loudly if you get it backwards inside an if — later this week — which is one more reason it's worth getting right now.
That is the whole idea for today. A comparison like ==, <, >, <=, or >= doesn't print anything by itself — it produces a boolean, and print is what shows you which one you got.
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 boundary
What do print(120 < 120) and print(120 == 120) display?
Compare your answer · self-reviewed
False, then True. Strict less-than excludes equality; equality includes only the matching case.
Explain the operator
How do limit = 120 and length == limit do different jobs?
Compare your answer · self-reviewed
The first stores a value. The second evaluates a comparison and produces True or False; it does not update either value.
Choose a new check
Why should you try values below, at and above the limit?
Compare your answer · self-reviewed
A rule can produce the visible answer yet mishandle equality. These three cases expose the boundary.
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.
- Python Booleans: Use Truth Values in Your Code — 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.