Boolean logic and logic gates

GCSE Computer Science revision notes, key terms and practice questions.

Logic gates

  • AND: the output is 1 only if both inputs are 1.
  • OR: the output is 1 if at least one input is 1.
  • NOT: the output is the opposite of the input.
  • (AQA) XOR: the output is 1 if the two inputs are different.

Truth tables

  • A truth table shows the output for every combination of inputs. 2 inputs give 4 rows; 3 inputs give 8 rows (2ⁿ rows for n inputs).
  • AND: 0 0 → 0, 0 1 → 0, 1 0 → 0, 1 1 → 1. OR: 0 0 → 0, 0 1 → 1, 1 0 → 1, 1 1 → 1. NOT: 0 → 1, 1 → 0.

Logic circuits and expressions

  • Gates can be joined into circuits. P = NOT (A AND B) is 0 only when A and B are both 1.
  • Work through a circuit one gate at a time, adding a column to the truth table for each gate's output.
  • Expressions may use symbols. OCR writes AND as ∧, OR as ∨ and NOT as ¬. AQA writes A AND B as A·B, A OR B as A + B, and NOT A as A with a bar over it.

Using logic

  • Logic is used in program conditions and in real systems. An alarm might sound if (a door is open OR a window is open) AND the alarm is set.

Key terms

Logic gate
An electronic component that carries out a Boolean operation on its inputs.
AND gate
Outputs 1 only when both inputs are 1.
OR gate
Outputs 1 when at least one input is 1.
NOT gate
Outputs the opposite of its single input.
XOR gate
Outputs 1 when the two inputs are different.
Truth table
A table showing the output for every possible combination of inputs.
Boolean expression
A statement using AND, OR and NOT that is either true or false.

Practise Boolean logic and logic gates: 12 questions