1) What do I need to do?
π― Your mission: Villain detector
Make a variable strength = 80.
Write 3 comparisons about strength in print(). The first must print True, the second False, the third True.
2) What do I need to know?
True and False
Computers love yes-or-no questions. In Python, yes is True and no is False (with capital letters!). These are called booleans.
Comparison signs ask questions:
== is it equal? β’ != is it NOT equal? β’ > bigger? β’ < smaller? β’ >= bigger or equal? β’ <= smaller or equal?
Watch out: = puts something in a box. == asks if two things are the same.
π§° Your toolkit for this mission
Everything you need to know to finish this lesson on your own:
Boolean
A value that is only ever True or False β a yes/no answer.
How to write it: Capital T and F, no quotes.
is_flying = True
Comparisons
Questions that answer True or False.
How to write it: > bigger β’ < smaller β’ >= bigger or equal β’ <= smaller or equal β’ == equal β’ != not equal.
strength = 80 print(strength > 50) # True
= vs ==
One = stores a value. Two == asks "are these the same?".
How to write it: Use == inside questions: answer == "yes".
mask = "yes" print(mask == "yes") # True
and / or / not
Combine questions.
How to write it: and = both must be True β’ or = at least one True β’ not flips TrueβFalse.
print(age >= 8 and mask == "yes")
Think about it
Look at this code. What happens next, and why? Say it in your own words.
print(5 <= 5) print(5 >= 6)
Watch & explore βΆ
Power-up: True and False
See it happen
1 / 3power = 80 print(power > 50)
True means yes. False means no. Is 80 bigger than 50? Yes!
3) Run the code & terminal output
Press βΆ RUN and your program's messages appear here!


Captain Py
Our next adventure is yours to create.
