python · level 1 · unit 4 · lesson 4
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Build bigger questions with , and .
and links two conditions. It gives True only when both sides are True. A cake needs flour and eggs: if either one is missing, there is no cake.
or gives True when at least one side is True, like a lie-in on Saturday or Sunday. not flips an answer, so not True is False.
A box holding True or False already counts as a condition. So if not has_eggs: reads like plain English: if we do not have eggs.
has_flour = True
has_eggs = False
if has_flour and has_eggs:
print("Time to bake a cake!")
if not has_eggs:
print("Off to the shop for eggs.") Write a full condition on each side, like day == "Saturday" or day == "Sunday".
guess first
Did you earn pudding? Make a guess.
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
ate_peas = True
ate_carrots = True
if ate_peas or ate_carrots:
print("Pudding time!")
else:
print("Veg first, please.")
your turn
Your turn. Get on the Twister.
The Twister has two rules: you must be 8 or older, and at least 120 cm tall. Choose an age and a height that get you on.
fix it
Since when are crisps healthy? Fix the check.
- Crisps are not an apple or a banana, yet it says healthy. Look at the right side of
or. "banana"on its own is not a question, and Python counts it asTrue. So theifalways runs.- Write the box name again:
snack == "apple" or snack == "banana", then press run.
nailed it
you can ask smarter questions now. :D
andneeds both sidesTrue.orneeds at least one.notflipsTruetoFalse, andFalsetoTrue.- Write a full condition on each side of
andoror.
new words in your collection
- and
- or
- not
This lesson isn’t saved. A free account remembers every lesson you finish.