AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Smaller files, smarter gates

Week 27 · 4.3–4.4 Data compression, logic gates and truth tables · 3 lessons
2

Gates that decide

Computing 8: Topics 4.3–4.4, pp. 268–282
GoalDescribe the NOT, AND and OR logic gates and complete their truth tables.
New words
logic gate · a tiny part of a circuit that takes inputs of 0 or 1 and gives one outputtruth table · a table that shows the output for every possible set of inputsinput, output · what goes into a gate, and what comes out
Explanation

Computers are built from circuits that contain many tiny logic gates. A gate takes inputs, which are 1 (on) or 0 (off), and gives one output. A NOT gate has one input and reverses it: 0 becomes 1 and 1 becomes 0. An AND gate has two inputs. Its output is 1 only when both inputs are 1. An OR gate also has two inputs. Its output is 1 when at least one input is 1. A truth table lists every possible input and its output. A NOT table has 2 rows, because one input has 2 values. AND and OR tables have 4 rows, because two inputs give 2 × 2 = 4 combinations.

GateInputsRuleRows in the table
NOT1reverses the input2
AND21 only if both are 14
OR21 if one or both are 14
Worked examples
InputOutput
01
10
The NOT gate. If the input is 0 the output is 1. If the input is 1 the output is 0.
ABOutput
000
010
100
111
The AND gate. Think of two keys that must both be turned to open a safe. Only one row has output 1: when both inputs are 1.
ABOutput
000
011
101
111
The OR gate. Think of two doors into a garden: you can enter by either one or both. Only one row has output 0: when both inputs are 0. Python’s not, and and or work in the same way on True and False.
Class activity

Human gates (no computer). Three people stand in a row. Each of two “input” people holds up a card: 1 (hand up) or 0 (hand down). The third person is the gate and shows the output. Play AND: the gate raises a hand only when both inputs are up. Play OR, and then NOT with one input. Write each result in a truth table as you go. For AND and OR, make sure you play all four combinations. Then check each table by comparing with a partner. Explain why there must be four rows for two inputs. Play again with the gate secretly chosen by a partner, and see if you can work out which gate it is.

Practice
1
Complete the AND table. Then say what a NOT gate outputs when its input is 0.
ABA AND B
00?
01?
10?
11?
2
Complete the OR table. The rows are in a different order from the lesson.
ABOutput
11?
01?
10?
00?
3
Here is a truth table with the gate name hidden. Which gate is it? Explain.
ABOutput
111
101
011
000
4
A gate has three inputs. How many rows has its truth table? (Hint: each input doubles the number of rows.)