Not raining
If it is not raining, we walk to school.
06TRUE OR FALSE? · NOT
not turns True into False and False into True. Then you can mix and, or, and not.
IN REAL LIFE
not is a question turned upside down.
If it is not raining, we walk to school.
If I am not sleepy, I read one more page.
If the baby is not asleep, we can play music.
TRUTH TABLE
not works on one answer, so its table is tiny.
raining | not raining |
|---|---|
| True | False |
| False | True |
A trick: not is a mirror. It always gives the opposite answer.
STEP BY STEP
Python flips with not first. Then it joins with and or or.
sunny = TrueIt is sunny.tired = FalsePyBot is not tired.if sunny and not tired:not tired: flip False into True. Then sunny and True: both are True. print("to the park!")The answer was True, so this path runs.LOOK FIRST
not goes in front of one question and flips only that one.
After flipping, Python joins the answers with and or or.
Python answers what is inside parentheses first. Use them to make a long question clear.
RUN IT
Guess first. Then run real Python and check.
raining = False
tired = False
if not raining and not tired:
print("let's play outside")
else:
print("let's stay in")What will Python show?
PyBot's hint
Ready. Press Run Python.
Pyodide 314.0.3 runs CPython in your browser with WebAssembly.
Open-source under the Mozilla Public License 2.0. License
Now change one thing: Change tired to True. What shows now? Then try raining = True.
YOUR TURN
Try each tiny question. A wrong answer becomes something to review.
Does the family walk?
not FalseWhat does Python answer?
tired = True
not tiredWhat does Python answer?
not 3 > 5What does Python answer?
not not TrueWhat does Python answer?
sunny = True
tired = True
sunny and not tiredWhat does Python answer?
(False or True) and not FalseWhat does Python answer?
PyBot wants to go outside when it is NOT raining. The question is upside down. Add one word.
go outsideOUTPUT
Want a fresh start? Clear only this page.
Next: is something inside a list or a word? Ask with in.