← All missions

βš–οΈ True or False?

🧠 Making Decisions & Math

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 / 3
power = 80
print(power > 50)
80 > 50
True βœ“

True means yes. False means no. Is 80 bigger than 50? Yes!

3) Run the code & terminal output

Code Lab 🐍Playground β€” experiment freely!
Hero Terminal

Press β–Ά RUN and your program's messages appear here!

Jungle Rescue
Jungle Rescue
Your superhero companion

Captain Py

Our next adventure is yours to create.