Boolean Logic & Truth Tables

You are stranded on an Island when you bump in to 3 people. Of the three people (Alice, Bill, Charlie):

  • One is a knight
  • One is a knave
  • One is a spy

On this island:

  • Knights always tell the truth
  • Knaves always lie
  • Spies can do either


Alice says: “Charlie is a knave.

Bill says: “Alice is a knight.”

Charlie says: “I am the spy.

Who is the knight, who the knave, and who the spy?

Boolean Logic

All data stored in computer systems is stored in binary format, which means that any calculations that are made must be done using only True and False values, this is known as Boolean logic.

Take for the instance the set up below:

boolean example1

When we run the code below, scratch will either say “True” or “False”, depending on whether you press the let arrow key.

Input – Press the let arrow key

process – No processing

Output – True

Truth Tables

When we are working out what possibilities exist for a particular Boolean logic structure, we can use a truth table to represent that data.

Using the previous example we can produce a simple truth table for the results.

Input Output
1 1
0 0

boolean and scratch

A Boolean AND gate works by the following rules:

  1. If both inputs are true, then the output will be True.
  2. Otherwise the output will be false

Challenge 1 – Complete the AND gate truth table.

Can you complete the truth table below?

Input 1 Input 2 Output
0 0 0
0 1 0

boolean or scratch

A Boolean OR gate works by the following logic:

  1. If either input is True, the output is True.
  2. If both inputs are True, the output is True.
  3. Otherwise the output is false.

Challenge 2

Can you work out the truth table for a Boolean OR gate?

Input 1 Input 2 Output
0 0 0
0 1 1

scratch boolean not

A Boolean NOT gate simply reverses whatever input is given.

  1. If the input is True, the output is False
  2. If the input is False, the output is True

Challenge 3

Can you write truth table for a not gate?

Input Output
0 1
1 0

Some logic requires combinations of different Boolean Logic Gate.

XOR – Exclusive OR


These are similar to OR gates but:

  1. If either input is True (but not both) the output is True
  2. Otherwise the output is false

Challenge 4

Can you use scratch blocks to make an XOR gate.

p.s. You can use the internet to help you if you like.

NAND – Not And

A NAND gate works with the following logic:

  1. If both inputs are True the output is False.
  2. Otherwise the output is true for all other cases
NOR – Not Or

Knights Vs Knaves Starter

Truth tables worksheet

Quizmaster truth tables questions.