←Previous page

06TRUE OR FALSE? · OR

or: one is enough.

or joins two questions. The answer is True when at least one answer is True.

IN REAL LIFE

Sometimes one is enough.

If either thing happens, the answer is yes.

Dessert

I am happy with cake or ice cream. Just one is enough!

No school

There is no school if it is Saturday or Sunday.

Jacket

I take a jacket if it is cold or if it is raining.

TRUTH TABLE

Every possible answer.

Two questions, four ways. or gives False in only one row.

rainingcoldraining or cold
TrueTrueTrue
TrueFalseTrue
FalseTrueTrue
FalseFalseFalse

A trick: or is easygoing. It is False only when both answers are False.

STEP BY STEP

Is it a day off?

Each side of or is a full question. One True is enough.

day = "sunday"A box keeps the word sunday.
if day == "saturday" or day == "sunday":Is it saturday? False. Is it sunday? True. One True is enough.
print("no school!")The answer was True, so this path runs.
day = "monday"Now the box keeps monday.
if day == "saturday" or day == "sunday":Is it saturday? False. Is it sunday? False. Both are False, so or gives False.
print("no school!")Skipped. Time for school.

RUN IT

Does PyBot need a jacket?

Guess first. Then run real Python and check.

1

Guess the result

raining = False cold = True if raining or cold: print("take a jacket") else: print("t-shirt day")

What will Python show?

jacket.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: Make both False. What changes? Then make both True.

YOUR TURN

One yes is enough.

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

0Completed
9Not tried
0Review
01

Dessert time

PyBot's rule: I am happy if there is cake or ice cream. Today there is ice cream, but no cake.

Is PyBot happy?

02

Two noes

False or False

What does Python answer?

03

One yes

raining = True snowing = False raining or snowing

What does Python answer?

04

Too small or too big?

n = 5 n < 0 or n > 10

What does Python answer?

05

Furry friend

pet = "cat" if pet == "dog" or pet == "cat": print("furry friend") else: print("other pet")

What does Python show?

06

Count the Falses

In the or table, how many rows give False?

07

and or or?

A secret door opens with a key ___ a password. Either one works.

Which word fits?

08

Fix PyBot's code

Oops, every day became a day off! Each side of or needs its own full question.

Goal output
school day
OUTPUT

Your work is saved here.

Want a fresh start? Clear only this page.

!
BIG IDEA

or is True when at least one answer is True.

Next: not, which flips an answer around.