Press ▶ Run to see what your program does.
Lesson 35: Comparisons and indents
Level 5, Python Thinks and Repeats. True or False with == and <, and why four spaces matter. The new word: comparison. It follows lesson 34, Decisions: if and else. Next comes lesson 36, for loops.
What the lesson explains
Compare anything. == != < > <= >= ask a question that is True or False.
True or False. Each comparison gives back True or False. == the same; != not the same; < > smaller, bigger.
What you do first
In your head. 10 > 3 The answer: "True".
The code on the screen
True or False. The editor shows 3 lines: print(5 == 5) / print(5 != 3) / print(2 > 9). Run it, and it prints "True", "True", "False".
What you practise
True or False?, "In your head": 10 > 3 The answer: "True". Then: "cat" == "Cat" The answer: "False". Then: 7 <= 7 The answer: "True".
Try it, "Three ways": Print Warm for a temperature of 20. The editor opens with: temp = 20 / if temp > 25: / print("Hot") / else: / print("Cold"). One way to write it: temp = 20 / if temp > 25: / print("Hot") / elif temp > 15: / print("Warm") / else: / print("Cold"). It prints: Warm.
Fix it, "Four spaces": Fix the IndentationError. The editor opens with: level = 5 / if level == 5: / print("Level 5!"). One way to write it: level = 5 / if level == 5: / print("Level 5!"). It prints: Level 5!.
What PlayBuddy and PlayType say
PlayBuddy: "Bigger, smaller, or the same? Python can compare anything."
PlayType: "One equals sign stores a value. Two equals signs ask a question."
Help in every lesson
Everything happens on a pretend computer in your browser, so nothing touches your real files. PlayBuddy and PlayType stand beside the board, cheer you on and say when it is your turn.
A green ring shows where to click the first time. After that you do it on your own, and if you slip twice the ring comes back.
Stars
The lesson has 5 things to do. Up to one slip in ten gives three stars, up to one in four gives two, and finishing always gives at least one. Stars and progress are saved in this browser only; there is no account.
About DayOneCode
DayOneCode is an independent learning site, not affiliated with or endorsed by Anthropic. Claude and Claude Code are trademarks of Anthropic.