The big ideaAND needs both, OR needs one, and NOT flips true and false.
How it works
AND is true only when both parts are true. The door needs the key AND the code.
OR is true when at least one part is true. The bell rings for the front OR the side button.
NOT flips an answer, so true becomes false and false becomes true.
Programs use these three words to build big rules out of small checks.
Zoe's three rules.
Example 1: AND at the door
Zoe's rule is if the key is turned AND the code is typed, open the door.
Max turns the key but types no code.
Only one part is true, so AND is false and the door stays shut.
Example 2: OR at the bell
The bell rings if the front button OR the side button is pressed.
Max presses the side button, so one part is true and the bell rings.
It also rings if he presses both. It stays silent only when he presses neither.
Example 3: NOT at the porch
The lamp rule is if NOT bright. Bo's sensor answers one question: is it bright?
At night the answer is no.
NOT flips no to yes, so the lamp lights. In daylight the answer is yes, NOT flips it to no, and the lamp stays off.
Example 4: Count the rows
Look at the four ways to press the front and side buttons.
The bell rings in 3 of them: front only, side only and both.
The door rule with AND opens in only 1 of its 4 rows: key and code both.
Four ways, two rules.
Words to know
AND
True only when both parts are true.
OR
True when at least one part is true.
NOT
Flips true to false and false to true.
sensor
A part that answers one question, like is it bright?
Watch out
AND needs both. With only one true part, AND is false.
OR needs only one. Both is fine too.
NOT flips the answer. It never keeps it.
Use AND when you want to be strict, and OR when you want to be flexible.
Try it
Max has the key but not the code. Does the AND door rule open?
Neither button is pressed. Does the OR bell ring?
The sensor says it is not bright. Does the NOT bright lamp rule light the lamp?
Is a coat when it is cold or windy an AND rule or an OR rule?
Max may come in only if he has the key and the code. AND, OR or NOT?
Answers: 1. No · 2. No · 3. Yes · 4. An OR rule · 5. AND
Try at homeAsk a grown-up for three rules in your home that use and, or, or not. For example: you can have a snack if you ask and you wash your hands. Which word is each rule using?
For grown-upsDo the Mission: ask your child to find three rules in your home that use and, or, or not, like you can have a snack if you ask and you wash your hands. Which word is each rule using?
Open these notes on screenScan the code, or go to tutorpip.com.