Pearson pseudocode: variables, selection and loops

Paper 1 questions may show algorithms in Pearson's own pseudocode (the command set in Appendix 5 of the specification). You need to read it fluently. You may write your own answers in any clear pseudocode or in a programming language.

Practise this lesson free (7 questions)

Variables, input and output

SET total TO 0 assigns a value. A constant is declared with CONST and set once.
RECEIVE mark FROM (INTEGER) KEYBOARD reads input and says its data type.
SEND total TO DISPLAY outputs a value. The & operator joins strings, so SEND 'Fred' & age TO DISPLAY with age 18 shows Fred18.
Operators: + - * / as usual, MOD (remainder) and DIV (whole-number division). Comparisons use = for equal and <> for not equal. Logic uses AND, OR and NOT. Comments start with #.

Selection

IF ... THEN, an optional ELSE, then END IF:
RECEIVE mark FROM (INTEGER) KEYBOARD
IF mark >= 50 THEN
SEND 'Pass' TO DISPLAY
ELSE
SEND 'Fail' TO DISPLAY
END IF
Python equivalent: if mark >= 50: print("Pass") else: print("Fail").

Four kinds of loop

FOR ... STEP -1 counts down. FOR EACH item FROM list DO ... END FOREACH visits every item.
PseudocodeWhat it doesPython
WHILE condition DO ... END WHILEChecks first; may run zero timeswhile condition:
REPEAT ... UNTIL conditionRuns at least once; stops when the condition is TrueNo direct equivalent
REPEAT 5 TIMES ... END REPEATRuns a fixed number of timesfor i in range(5):
FOR i FROM 1 TO 10 DO ... END FORCounts from 1 to 10, including 10for i in range(1, 11):

Tracing pseudocode

Follow it line by line, exactly as for code:
SET total TO 0
FOR count FROM 1 TO 4 DO
SET total TO total + count
END FOR
SEND total TO DISPLAY
total goes 1, 3, 6, 10, so it outputs 10. Note that FOR ... FROM 1 TO 4 includes 4, unlike range(1, 4) in Python.
Worked example

What is output by this pseudocode?
SET number TO 1
REPEAT
SET number TO number * 3
UNTIL number > 50
SEND number TO DISPLAY

  1. REPEAT runs the body first: number becomes 3, then 9, 27 and 81.
  2. After each pass the condition is checked: 81 > 50 is the first True result.
  3. The loop ends and 81 is sent to the display.

Answer: 81

Key idea

Pearson pseudocode uses SET ... TO for assignment, RECEIVE and SEND for input and output, & to join strings, MOD and DIV, IF ... THEN ... ELSE ... END IF, and WHILE, REPEAT ... UNTIL, REPEAT n TIMES and FOR ... FROM ... TO loops. FOR includes its end value.

Key words
Selection
Choosing which code runs using a condition, such as if, elif and else.
Assignment
Storing a value in a variable, such as total = 0.
MOD and DIV
Remainder and integer division. Python: % and //
IF ... THEN ... ELSE ... END IF
Selection. Python: if ...: then else:
SET total TO 0
Assignment. Python: total = 0
Constant
A named value that does not change while the program runs.

All GCSE and International GCSE Computer Science key terms and definitions →

Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. What is output?
    SET count TO 1
    REPEAT 4 TIMES
    SET count TO count + 3
    END REPEAT
    SEND count TO DISPLAY

    Show the answer

    Answer: 13

    count: 1 → 4 → 7 → 10 → 13.

  2. What is output?
    SET n TO 10
    WHILE n < 5 DO
    SET n TO n - 1
    END WHILE
    SEND n TO DISPLAY

    Show the answer

    Answer: 10

    10 < 5 is false at the start, so the loop body never runs and n stays 10.

Check you have got it

Answer 7 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

Checked by the GCSE-ready editorial team, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.

Related lessons