Dessert
I am happy with cake or ice cream. Just one is enough!
06TRUE OR FALSE? · OR
or joins two questions. The answer is True when at least one answer is True.
IN REAL LIFE
If either thing happens, the answer is yes.
I am happy with cake or ice cream. Just one is enough!
There is no school if it is Saturday or Sunday.
I take a jacket if it is cold or if it is raining.
TRUTH TABLE
Two questions, four ways. or gives False in only one row.
raining | cold | raining or cold |
|---|---|---|
| True | True | True |
| True | False | True |
| False | True | True |
| False | False | False |
A trick: or is easygoing. It is False only when both answers are False.
STEP BY STEP
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
Guess first. Then run real Python and check.
raining = False
cold = True
if raining or cold:
print("take a jacket")
else:
print("t-shirt day")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: Make both False. What changes? Then make both True.
YOUR TURN
Try each tiny question. A wrong answer becomes something to review.
Is PyBot happy?
False or FalseWhat does Python answer?
raining = True
snowing = False
raining or snowingWhat does Python answer?
n = 5
n < 0 or n > 10What does Python answer?
pet = "cat"
if pet == "dog" or pet == "cat":
print("furry friend")
else:
print("other pet")What does Python show?
In the or table, how many rows give False?
Which word fits?
Oops, every day became a day off! Each side of or needs its own full question.
school dayOUTPUT
Want a fresh start? Clear only this page.
Next: not, which flips an answer around.