Kramizo
Log inSign up free
Home › OCR GCSE Computer Science › Computational Logic
OCR · GCSE · Computer Science · Revision Notes

Computational Logic

1,761 words · Last updated October 2026

⚡
Ready to practise? Test yourself on Computational Logic with instantly-marked questions.
Practice now →

What you'll learn

Computational logic explains how computers make decisions using simple electronic switches. In OCR GCSE Computer Science (J277, section 2.4) you need to know why computers use binary to represent data and instructions, the three logic gates AND, OR and NOT, their symbols and truth tables, how to combine gates into circuits with up to three inputs, how to write and evaluate Boolean expressions, and how logic is used in programming. This guide explains each idea and works through the circuit and truth-table questions that commonly appear.

Logic questions are highly reliable sources of marks once you know the method: list every input combination systematically, work through each gate in order, and check the output column. Most lost marks come from missing a row or reading a gate the wrong way.

Key terms and definitions

Binary — A number system with two digits, 0 and 1, used by computers because their circuits have two states.

Logic gate — An electronic component that takes one or more binary inputs and produces a single binary output according to a rule.

AND gate — Outputs 1 only if all of its inputs are 1.

OR gate — Outputs 1 if at least one of its inputs is 1.

NOT gate — Outputs the opposite of its single input; also called an inverter.

Truth table — A table showing the output of a logic gate or circuit for every possible combination of inputs.

Boolean expression — An expression using variables and the operators AND, OR and NOT, which evaluates to True or False.

Logic circuit — A combination of logic gates connected together to produce a required output.

Core concepts

Why computers use binary

A computer's processor contains billions of transistors that act as switches. A switch has two states: off and on, represented as 0 and 1. Using only two states makes circuits simpler, cheaper and more reliable, because it is easy to tell the difference between "no voltage" and "voltage" even if there is some electrical noise. All data — numbers, text, images, sound — and all program instructions are therefore represented in binary.

Representing True and False

In logic, 1 means True and 0 means False. Logic gates combine these values to make decisions, and millions of gates working together form the arithmetic and control circuits of the CPU.

The AND gate

An AND gate has two (or more) inputs. The output is 1 only when both inputs are 1.

A B A AND B
0 0 0
0 1 0
1 0 0
1 1 1

Boolean notation used by OCR: A AND B, also written A ∧ B. Its symbol is drawn as a D-shape with a flat input side.

Example: a car's engine starts only if the key is turned and the brake is pressed.

The OR gate

The output is 1 if A or B (or both) is 1.

A B A OR B
0 0 0
0 1 1
1 0 1
1 1 1

Notation: A OR B, also A ∨ B. The symbol has a curved input side and a pointed output.

Example: an alarm sounds if the front door or the back door is opened.

The NOT gate

A NOT gate has one input and outputs the opposite.

A NOT A
0 1
1 0

Notation: NOT A, also ¬A. The symbol is a triangle with a small circle at the output.

Example: a light comes on when it is not daytime.

Combining gates

Gates can be connected so that the output of one becomes the input of another. For example, the expression

Q = (A AND B) OR NOT C

means: work out A AND B, work out NOT C, then OR the two results together. In a circuit, A and B feed an AND gate; C feeds a NOT gate; both outputs feed an OR gate, whose output is Q.

Building truth tables

For n inputs there are 2ⁿ rows: 4 rows for two inputs, 8 rows for three inputs. List the inputs systematically by counting in binary: 000, 001, 010, 011, 100, 101, 110, 111. Add a column for each intermediate result, then the final output.

For Q = (A AND B) OR NOT C:

A B C A AND B NOT C Q
0 0 0 0 1 1
0 0 1 0 0 0
0 1 0 0 1 1
0 1 1 0 0 0
1 0 0 0 1 1
1 0 1 0 0 0
1 1 0 1 1 1
1 1 1 1 0 1

Intermediate columns make the working easy to check and earn method marks.

Writing expressions from descriptions and circuits

When a problem is described in words, identify the inputs, look for the words and, or and not, and use brackets to show which parts are calculated first.

"A greenhouse fan (F) switches on if the temperature is high (T) and the window is closed (W is 0), or if the humidity is high (H)."

F = (T AND NOT W) OR H

When given a circuit diagram, work from the inputs towards the output, writing the expression for each gate in turn.

Logic in programming

The same operators appear in code conditions:

if age >= 13 AND hasPermission == True then
    print("Access allowed")
endif

if NOT loggedIn then
    print("Please log in")
endif

Understanding truth tables helps you predict when a condition will be true and avoid logic errors, such as using OR where AND was needed.

Checking whether two expressions are equivalent

Truth tables can show whether two different expressions always give the same output. Compare NOT (A AND B) with (NOT A) OR (NOT B):

A B A AND B NOT (A AND B) NOT A NOT B (NOT A) OR (NOT B)
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0

The two output columns match on every row, so the expressions are equivalent. You do not need to learn rules for simplifying expressions at GCSE, but this method lets you check any claim that two circuits behave the same way.

Logic gates in real systems

Every decision a computer makes is ultimately built from gates. A burglar alarm might sound when the system is armed AND (a door is opened OR movement is detected) — that is, Alarm = Armed AND (Door OR Motion). Inside the CPU, combinations of gates add binary numbers, compare values and decide which instruction to run next. Because each gate switches in a tiny fraction of a second and a processor contains billions of transistors, very complex behaviour can be produced from these three simple rules.

Worked examples

Example 1: Evaluating an expression

Evaluate Q = NOT (A OR B) when A = 0 and B = 1.

A OR B = 0 OR 1 = 1. NOT 1 = 0. So Q = 0.

Example 2: Completing a two-input table

Complete the truth table for Q = A AND NOT B.

A B NOT B Q
0 0 1 0
0 1 0 0
1 0 1 1
1 1 0 0

The output is 1 only when A is 1 and B is 0.

Example 3: Writing an expression

A security light (L) turns on when it is dark (D) and movement (M) is detected. Write the Boolean expression. (1 mark)

Answer: L = D AND M.

Example 4: Reading a circuit

A circuit sends inputs A and B into an OR gate. Its output and input C go into an AND gate, producing Q. Write the expression and find Q when A = 1, B = 0, C = 0.

Answer: Q = (A OR B) AND C. A OR B = 1; 1 AND 0 = 0. So Q = 0.

Common mistakes and how to avoid them

  • Missing rows. Three inputs always need eight rows; count in binary to list them.
  • Confusing AND and OR. AND needs all inputs to be 1; OR needs at least one.
  • Forgetting brackets. (A AND B) OR C is different from A AND (B OR C).
  • Giving NOT two inputs. NOT only ever has one input.
  • Skipping intermediate columns. They make errors easier to spot and earn method marks.
  • Drawing the wrong symbol. Practise drawing the AND, OR and NOT shapes clearly.

Exam technique for "Computational Logic"

  • Write the input combinations in binary counting order.
  • Add a column for each gate before the final output.
  • When drawing circuits, label every input and the output, and check each gate's inputs match the expression.
  • For word problems, underline "and", "or" and "not" and decide where brackets are needed.

Quick revision summary

  • Computers use binary because transistors are two-state switches; 1 = True, 0 = False.
  • AND: 1 only if both inputs are 1. OR: 1 if at least one input is 1. NOT: reverses its single input.
  • Truth tables have 2ⁿ rows — 4 for two inputs, 8 for three.
  • Combine gates by feeding outputs into inputs; use brackets in expressions.
  • Work through circuits from inputs to output, using intermediate columns.
  • The same logic applies to conditions in programs.

Test yourself on Computational Logic

5 quick questions · instantly marked

Loading questions…

Computational Logic: common questions

What are the most common mistakes in Computational Logic?

Missing rows: Three inputs always need eight rows; count in binary to list them. Confusing AND and OR: AND needs all inputs to be 1; OR needs at least one. Forgetting brackets: (A AND B) OR C is different from A AND (B OR C).

Where can I practise Computational Logic questions for free?

Kramizo has free OCR GCSE Computer Science practice questions on Computational Logic, each marked instantly with a full explanation. No card is required.

Free for GCSE students

Lock in Computational Logic with real exam questions.

Free instantly-marked OCR GCSE Computer Science practice — 45 questions a day, no card required.

Try a question →See practice bank