KS3 · Computer Science

Building truth tables

Two inputs, four ways to set them. A truth table proves you've checked every one, and today you'll build one without missing a row.

Computer Science · Truth tables

Build the truth table for NOT (A AND B)

This is the method you'll use for every table: set out the columns, list the rows in order, then work one column at a time from left to right.

Try this: cover the last two columns with a finger, and say each row's answers out loud before you press Next.

ABA AND BNOT (A AND B)
0001
0101
1001
1110
A=0, B=0, A AND B=0 → NOT (A AND B) = 1

Output

Columns: A | B | A AND B | NOT (A AND B)

Step 1: Set out the columns. One for each input (A and B), one for the part in brackets (A AND B), and one for the whole expression on the right. The brackets tell you which part to work out first.

1 / 7

Use Next and Back to step through the working. The highlighted row is the one being worked on.

Step 1 of 7: Set out the columns. One for each input (A and B), one for the part in brackets (A AND B), and one for the whole expression on the right. The brackets tell you which part to work out first..

Watch out: Don't jump straight to the last column. Work out the part in brackets first, in its own column. Then NOT just flips each answer in that column.

Computer Science · Counting rows

Why three inputs make eight rows

Choose a value for A, then B, then C. Every path you can walk is one row of a three-input truth table.

Choose A → Choose B → Choose C

  • Each path through the tree is one combination of inputs. It isn't a number to add up. The order you list them in doesn't change any output; it just makes sure you never miss one or write one twice.

2 × 2 × 2 = 8 rows in the truth table, and the tree ends 8 times.

On Start: no inputs chosen yet. 2 branches to choose from.

Read the ends from top to bottom: 000, 001, 010, 011, 100, 101, 110, 111. That's binary counting order, and you get it for free by always trying 0 before 1.

Spot the slip

One row of this OR table is wrong

Build the truth table for A OR B.

A pupil's working — which line goes wrong?

Your turn

Build the table for A OR NOT B

Work row by row. Tick a box if that column is 1 in that row, and leave it empty for 0. Do NOT B first, because NOT here applies to B only.

Row 00: A = 0, B = 0
Row 01: A = 0, B = 1
Row 10: A = 1, B = 0
Row 11: A = 1, B = 1

Read the table

Which operator made this column?

Each card is a finished output column, with rows in binary counting order. Decide which operator made it.

Still to sort

AND (0)

Output is 1 only when both inputs are 1.

Where the line is: AND has a single 1, in row 11. OR has a single 0, in row 00. Don't mix up which one is the odd one out.

OR (0)

Output is 0 only when both inputs are 0.

NOT (0)

One input: the output is the opposite of it.

Needs more than one operator (0)

No single AND, OR or NOT gives this column.

Where the line is: Three 1s and one 0 doesn't automatically mean OR. Check where the 0 is. For OR it's always in row 00.

5 of 5 still to sort.

Predict, then check

Here's an example from a game program, made up to show the idea.

A game opens a door only when the condition hasKey AND hasMap is true. Using the truth table for AND, which rows open the door?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

A truth table is a promise that you've checked every possible input. Count the rows, list them in order, and work one column at a time.

What you need to know

  • A truth table has one column for each input and one for the output, and one row for every possible combination of inputs. Inputs and outputs are 1 (true) or 0 (false).
  • The number of rows is 2 raised to the number of inputs: 1 input → 2 rows, 2 inputs → 4 rows, 3 inputs → 8 rows. List them in binary counting order so none is missed.
  • For a combined expression, add a column for each part (brackets first), work it out row by row, then use it to work out the final output column.

The big picture

A truth table shows the output of a Boolean expression for every possible combination of inputs. Each input is 1 (true) or 0 (false), so the number of rows is 2 raised to the number of inputs: 2 rows for one input, 4 for two and 8 for three. List the rows in binary counting order (00, 01, 10, 11) so none is missed. For an expression that combines operators, give each part its own column, working the brackets first, then use those columns to find the output. You can read a finished table to find an output, name the operator, or see which inputs make the output true.

Key points

1A Boolean expression combines inputs that are each true or false using AND, OR and NOT. Its output is also true or false. True is usually written as 1 and false as 0.
2A truth table lists every possible combination of inputs, one per row, and shows the output for each.
3Rows needed = 2 raised to the number of inputs (2, 4, 8 for one, two, three inputs). Binary counting order (00, 01, 10, 11) makes sure no row is missed.
4NOT flips its input. AND gives 1 only when both inputs are 1. OR gives 1 when at least one input is 1, including when both are, so only row 00 gives 0.
5For NOT (A AND B) or A OR NOT B, work out the intermediate part (A AND B, or NOT B) in its own column first, then use it for the final column.
6A finished table can tell you the output for given inputs, which operator or expression it shows, and which inputs make the output true. It also describes how a logic gate behaves (1 = on, 0 = off) and helps check conditions in programs.

Worked example

Problem

Build the truth table for (A AND B) OR C.

⚠ Watch out

Treating OR as 'one or the other but not both', and writing 0 in row 11. Logic OR gives 1 whenever at least one input is 1, so row 11 gives 1 and only row 00 gives 0.

🧠

Memory hook

Count, order, climb. Count the rows (double for every input), put them in order (00, 01, 10, 11), then climb the staircase: inputs, then brackets, then the whole expression.

✓

Check yourself

Quick check: how many rows does a three-input table need? And what does NOT (A OR B) give in row 01? (8 rows. A OR B is 1 there, so NOT gives 0.)

Flashcards

(14)
What does a truth table show?
The output of an expression for every possible combination of inputs, with one row per combination.
How do you work out how many rows a truth table needs?
2 raised to the number of inputs: 1 input → 2 rows, 2 inputs → 4 rows, 3 inputs → 8 rows.
In what order do you list the rows of a two-input table?
Binary counting order: 00, 01, 10, 11.
Why list the rows in binary counting order?
So that no combination of inputs is missed or written twice. The order doesn't change any output.
What is an intermediate column?
A column for one part of a combined expression, such as A AND B, worked out row by row before the final output.
In NOT (A AND B), which part do you work out first?
A AND B, because it's in brackets. Then NOT flips each answer in that column.
In A OR NOT B, which column comes before the output?
NOT B. The NOT applies to B only, so it gets its own column, then OR uses it.
When does A AND B give 1?
Only when A is 1 and B is 1 (row 11). Rows 00, 01 and 10 give 0.
When does A OR B give 0?
Only in row 00, when both inputs are 0. Row 11 gives 1.
What does NOT do to its input?
Flips it: 0 becomes 1 and 1 becomes 0.
What values can a Boolean input or output take?
True or false, usually written as 1 and 0.
In a truth table for a logic gate, what do 1 and 0 mean?
On and off.
Name three things you can read from a finished truth table.
The output for given inputs, which operator or expression it shows, and which inputs make the output true.
How can a truth table help when writing a program?
It shows which input combinations make a condition true, such as two tests joined with AND or OR.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More KS3 Computer Science topics

See the full KS3 Computer Science curriculum →

How this lesson was checked. This KS3 Computer Sciencelesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 2 October 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.