←Previous page

06TRUE OR FALSE? · NOT

not: flip the answer.

not turns True into False and False into True. Then you can mix and, or, and not.

IN REAL LIFE

We say “not” all the time.

not is a question turned upside down.

Not raining

If it is not raining, we walk to school.

Not sleepy

If I am not sleepy, I read one more page.

Not asleep

If the baby is not asleep, we can play music.

TRUTH TABLE

Only two rows.

not works on one answer, so its table is tiny.

rainingnot raining
TrueFalse
FalseTrue

A trick: not is a mirror. It always gives the opposite answer.

STEP BY STEP

Mix them together.

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

Three rules for mixing.

not flips one answer

not goes in front of one question and flips only that one.

and needs both, or needs one

After flipping, Python joins the answers with and or or.

( ) go first

Python answers what is inside parentheses first. Use them to make a long question clear.

RUN IT

Can PyBot play outside?

Guess first. Then run real Python and check.

1

Guess the result

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?

play.pyREAL PYTHON
OUTPUT
Ready. Press Run Python.
Python runs here thanks to Pyodide ♥

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

Flip it, then mix it.

Try each tiny question. A wrong answer becomes something to review.

0Completed
9Not tried
0Review
01

Walk to school?

Family rule: if it is not raining, we walk to school. Today it is raining.

Does the family walk?

02

Flip False

not False

What does Python answer?

03

Flip a box

tired = True not tired

What does Python answer?

04

Flip a comparison

not 3 > 5

What does Python answer?

05

Flip it twice

not not True

What does Python answer?

06

Sunny but tired

sunny = True tired = True sunny and not tired

What does Python answer?

07

Parentheses first

(False or True) and not False

What does Python answer?

08

Fix PyBot's code

PyBot wants to go outside when it is NOT raining. The question is upside down. Add one word.

Goal output
go outside
OUTPUT

Your work is saved here.

Want a fresh start? Clear only this page.

!
BIG IDEA

not flips an answer. and, or, and not build bigger questions.

Next: is something inside a list or a word? Ask with in.