← Back to course
Code Crew G3 / Week 09 / Thursday
4/6
Week 09 Β· Boolean Logic

Thursday

// True, false, AND/OR

Thursday: Logic Gate Puzzles

Rocket builds an alarm for the treehouse door. It beeps all day long! Rocket laughs. "Oops. Back to the drawing board."

"When should it beep?" Raven asks. Rocket thinks. "Only at night, when the door is open."

Nova projects a small picture of a gate. "A gate takes inputs and gives one output," she says. Let's help fix the alarm.

A LOGIC GATE is a tiny machine that takes Boolean inputs and gives one output. Read each circuit:

INPUT A  ─┐
          AND──→ OUTPUT
INPUT B  β”€β”˜

Fill the output

ABOUTPUT
TT?
TF?
FF?
WHY THIS EXERCISEComputer chips are built from tiny switches called transistors, which make AND/OR/NOT logic gates.
INPUT A  ─→ NOT ─→ OUTPUT
AOUTPUT
T?
F?

Combine the Gates

Read carefully:

alarm =  (door is OPEN)  AND  (it is NIGHT)
doornight?alarm?
closedyes?
openyes?
openno?
closedno?
WHY THIS EXERCISEA home alarm could use this pattern: 'IF door open AND night β†’ alert.'

Now write your own rule for: 'I get a snack'.

snack =

Gate Practice

Computers use tiny logic gates. Each gate takes TRUE or FALSE inputs and gives one output.

ABOR gate output
TT?
TF?
FT?
FF?
WHY THIS EXERCISEOR gates and AND gates follow the same rules as our truth tables.
doornight?alarm = door OPEN AND NIGHT
openyes?
openno?
closedyes?
closedno?
WHY THIS EXERCISEReal alarms use rules like this to decide when to ring.
WHAT COMES OUT?
  • Read the question.
  • Tap your answer.
An AND gate gets TRUE and FALSE. What comes out?
An OR gate gets FALSE and FALSE. What comes out?
A NOT gate gets FALSE. What comes out?
alarm = door OPEN AND NIGHT. It is day and the door is open. Does the alarm ring?
lights_on = dark AND someone home. Both are TRUE. What is lights_on?
It is dark. Nobody is home. What is lights_on?
Which gate flips a value?
Try it
Be a human AND gate with two grown-ups.
Each grown-up shows thumbs up for TRUE or thumbs down for FALSE.
You show thumbs up only if both of theirs are up.
← Wednesday