Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 8+ · Coding · Decisions
And, or, not
The word• AND• OR• NOTWhat it needs• both parts true• at least one true• flips the answer
Three small words build big rules.
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.

1if key turned AND code typed2 open the door3if front OR side button4 ring the bell5if NOT bright6 light the porch lamp
Zoe's three rules.

Example 1: AND at the door

  1. Zoe's rule is if the key is turned AND the code is typed, open the door.
  2. Max turns the key but types no code.
  3. Only one part is true, so AND is false and the door stays shut.

Example 2: OR at the bell

  1. The bell rings if the front button OR the side button is pressed.
  2. Max presses the side button, so one part is true and the bell rings.
  3. It also rings if he presses both. It stays silent only when he presses neither.

Example 3: NOT at the porch

  1. The lamp rule is if NOT bright. Bo's sensor answers one question: is it bright?
  2. At night the answer is no.
  3. 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

  1. Look at the four ways to press the front and side buttons.
  2. The bell rings in 3 of them: front only, side only and both.
  3. The door rule with AND opens in only 1 of its 4 rows: key and code both.
AND (door opens)• yes, yes: opens• yes, no: shut• no, yes: shut• no, no: shutOR (bell rings)• yes, yes: rings• yes, no: rings• no, yes: rings• no, no: silent
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

Try it

  1. Max has the key but not the code. Does the AND door rule open?
  2. Neither button is pressed. Does the OR bell ring?
  3. The sensor says it is not bright. Does the NOT bright lamp rule light the lamp?
  4. Is a coat when it is cold or windy an AND rule or an OR rule?
  5. 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.