KeyStage

Key Stage 3 computing · Data and logic

KS3 Boolean logic: AND, OR and NOT for parents

Boolean logic is the system of true and false statements that sits underneath every computer decision. In Years 7 to 9, children learn the simple operators AND, OR and NOT, how to show what they do in a truth table, and how the same logic appears both in electronic circuits and in the conditions of a program.

Boolean logic: AND, OR, NOT, explained

A Boolean value has only two possibilities: true or false, which computers store as 1 or 0. Statements such as “the door is open” or “the score is above 50” are either true or false at any moment. Boolean operators combine these simple statements into more interesting ones. The curriculum gives AND, OR and NOT as examples, and those three are the ones most schools teach at this stage.

AND is true only when both inputs are true. “You can enter if you have a ticket AND you are over 12” fails if either part is false. OR is true when at least one input is true, including when both are. NOT flips a value: NOT true is false, and NOT false is true. Everyday speech is looser than this. When someone says “you can have tea or coffee”, they probably mean one but not both, whereas in Boolean logic OR includes both being true.

Because there is no room for doubt, the behaviour of an operator can be written in a truth table, which lists every combination of inputs and shows the output for each. With two inputs there are four rows, with three inputs there are eight, and every extra input doubles the number of rows. Children also learn that brackets matter. In most languages NOT is worked out first, then AND, then OR, so A AND B OR C does not mean the same as A AND (B OR C).

The curriculum asks for “some of its uses in circuits and programming”. In circuits, a logic gate is an electronic component that takes one or more inputs (usually one or two at this stage), each either high or low voltage, and produces an output following one of these rules. Gates are built from tiny electronic switches called transistors, and a modern processor contains billions of transistors. In programs, the same logic sits in the conditions used by if statements and loops, such as if age >= 12 and height >= 140. Schools usually draw gates with standard symbols and may use simulation software or a physical kit, though the choice is the school’s.

By the end of Key Stage 3 a child should be able to say what AND, OR and NOT do, complete a truth table for a simple combination, read a small logic diagram and write a correct condition in code. This links to the curriculum’s aim that pupils understand logic as one of the fundamental ideas of computer science, alongside algorithms and data representation.

Words your child will hear

Boolean
A value that can only be true or false, often stored as 1 or 0.
AND
True only if both inputs are true.
OR
True if at least one input is true, including when both are.
NOT
Flips the input: true becomes false and false becomes true.
Truth table
A table listing every possible combination of inputs and the output for each.
Logic gate
An electronic component that applies AND, OR, NOT or another rule to its inputs.
Condition
A statement in a program that is either true or false, used to decide what happens next.

What the National Curriculum says

The programme of study for Key Stage 3 says:

  • Pupils should be taught to understand simple Boolean logic [for example, AND, OR and NOT] and some of its uses in circuits and programming; understand how numbers can be represented in binary, and be able to carry out simple operations on binary numbers [for example, binary addition, and conversion between binary and decimal]
  • Aim: pupils can understand and apply the fundamental principles and concepts of computer science, including abstraction, logic, algorithms and data representation.

Objectives from the National Curriculum in England, © Crown copyright, used under the Open Government Licence v3.0.

A worked example

An alarm sounds (Q) if the system is armed (A) AND either the door (D) OR the window (W) is open. Write the rule, complete the truth table and write the condition in code.

  1. Write the rule using brackets so the order is clear. The door and window part is a pair joined by OR, and the armed part joins that with AND. Three inputs means 2 × 2 × 2 = 8 rows.
    Q = A AND (D OR W)
  2. Work out the bracket first for every row. D OR W is 1 if either is 1 and is 0 only when both are 0.
    A D W | D OR W
    0 0 0 |   0
    0 0 1 |   1
    0 1 0 |   1
    0 1 1 |   1
    1 0 0 |   0
    1 0 1 |   1
    1 1 0 |   1
    1 1 1 |   1
  3. Now apply AND with A. If A is 0 the output is always 0. If A is 1, the output copies the bracket column.
    A D W | D OR W | Q
    0 0 0 |   0    | 0
    0 0 1 |   1    | 0
    0 1 0 |   1    | 0
    0 1 1 |   1    | 0
    1 0 0 |   0    | 0
    1 0 1 |   1    | 1
    1 1 0 |   1    | 1
    1 1 1 |   1    | 1
  4. Write it as a condition in code. The brackets matter: without them, armed and door_open or window_open would be worked out as (armed and door_open) or window_open, and the alarm would sound for an open window even when the system is switched off.
    if armed and (door_open or window_open):
        sound_alarm()

The alarm sounds in 3 of the 8 cases: armed with the door open, armed with the window open, or armed with both open. If the system is not armed, it never sounds.

Common mistakes and how to help

Thinking OR means one or the other but not both

In ordinary conversation “or” often excludes both, as in “tea or coffee”. Children carry that meaning into logic and write 0 in the row where both inputs are 1.

What helps: Say “OR means at least one”. Try a rule such as “you may wear a coat OR a jumper”, and ask whether wearing both breaks it. If not, it is OR in the Boolean sense.

Leaving out brackets and assuming the computer reads the condition the way they meant it

In English, “armed and door open or window open” can be heard in more than one way. The computer works out AND before OR, so A AND B OR C means (A AND B) OR C, which may not be what the child had in mind.

What helps: Always put brackets in, even when not needed. Work out the bracket as its own column in the truth table, as in the example above, before combining.

Leaving out rows of a truth table

Children list the combinations as they think of them and miss some, especially with three inputs, so the table looks complete but is not.

What helps: Fill the table systematically, like counting in binary: 000, 001, 010, 011, 100, 101, 110, 111. Check that the number of rows is 2 raised to the number of inputs.

Writing if x == 12 or 13 in code

In English “is 12 or 13” makes sense, but a computer needs two complete conditions on each side of the or. Written the short way, the second part is not a comparison at all, and in Python, for example, the condition is always treated as true, whatever x is.

What helps: Say the full sentence out loud: “x equals 12, or x equals 13”. Then write both comparisons: x == 12 or x == 13.

How to help at home

  • Make a truth table for a household rule. Pick a real rule, such as “we go to the park if it is not raining AND (it is the weekend OR it is after school)”. Ask your child to list every combination and mark when the answer is yes. Arguing about whether a row is right is the point.
  • Hunt for “or” that is not Boolean. Collect everyday uses of “or” and decide whether they include both. “Would you like soup or salad?” usually means one only. Noticing the difference makes the logic version clearer.
  • Link switches to AND and OR. If your child has a simple low-voltage kit from science with a small battery, bulb and switches, two switches one after the other make an AND, because both must be closed. Two switches side by side make an OR. Use small batteries from a kit only, never mains electricity.
  • Sort playing cards with AND, OR and NOT. Using an ordinary pack of 52 cards, ask your child to predict, then check, how many cards match each rule. Red AND a picture card (jack, queen or king) gives 6. Red OR a picture card gives 32, because the 26 red cards and the 6 black picture cards both count. NOT red gives 26. Notice how AND narrows the group and OR widens it.
  • Read conditions aloud. When your child shows you a program with an if statement, ask them to read the condition as a sentence and tell you exactly when it is true. If they struggle, make up three test cases together and work them out.

More on data and logic

Everything in Key Stage 3 computing

Updated .