This set covers the whole of pseudocode for the applicable syllabus: assignment, comparison, validation, loops and notation choice. Questions run from easier to harder. Every question is original.
Use a pencil and a trace table for each one before opening the answer. The restricted pseudocode trace trainer and the Python reasoning sandbox are good for checking afterwards, and the non-calculator practice tool helps if the arithmetic slows you down.
Questions
1. Trace and give the output.
X ← 5
Y ← X + 3
X ← Y * 2
OUTPUT X, Y
Show answer
| Line | X | Y |
|---|---|---|
| X ← 5 | 5 | |
| Y ← X + 3 | 5 | 8 |
| X ← Y * 2 | 16 | 8 |
Output: 16 8.
2. Score holds 50. What is output?
Score ← 50
IF Score = 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Retry"
ENDIF
Show answer
The first line is an assignment. The condition Score = 50 is a comparison and is TRUE, so the output is Pass. Score is unchanged.
3. Write pseudocode that reads two numbers and outputs the larger one.
Show answer
INPUT A
INPUT B
IF A > B THEN
OUTPUT A
ELSE
OUTPUT B
ENDIF
Test with 6 and 9: 6 > 9 is FALSE, so the output is 9. Test with 4 and 4: the ELSE branch gives 4, which is correct.
4. Trace the swap using a temporary variable, with A = 3 and B = 9.
Temp ← A
A ← B
B ← Temp
OUTPUT A, B
Show answer
| Line | A | B | Temp |
|---|---|---|---|
| start | 3 | 9 | |
| Temp ← A | 3 | 9 | 3 |
| A ← B | 9 | 9 | 3 |
| B ← Temp | 9 | 3 | 3 |
Output: 9 3. Without Temp, the second line would overwrite A and lose the 3.
5. A password must have 8 to 12 characters. Write a validation loop, then say what happens for the input “abc12”.
Show answer
INPUT Password
WHILE LENGTH(Password) < 8 OR LENGTH(Password) > 12 DO
OUTPUT "Use 8 to 12 characters"
INPUT Password
ENDWHILE
“abc12” has 5 characters. 5 < 8 is TRUE, so the loop runs, the prompt is shown and a new password is requested.
6. Trace and give the output.
N ← 1
Total ← 0
WHILE N <= 5 DO
Total ← Total + N * N
N ← N + 1
ENDWHILE
OUTPUT Total
Show answer
The squares are 1, 4, 9, 16 and 25, added in turn: 1, 5, 14, 30, 55. When N becomes 6, 6 <= 5 is FALSE. Output: 55. Check: 1 + 4 + 9 + 16 + 25 = 55.
7. This loop should show 100, 90, … down to 10. Find the fault and repair it.
Value ← 100
WHILE Value > 0 DO
OUTPUT Value
Value ← Value + 10
ENDWHILE
Show answer
Value increases, so it moves away from 0 and the loop never ends. Change the update to Value ← Value - 10. Then the outputs are 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, which is 10 values. Value ends at 0 and the test 0 > 0 is FALSE.
8. Trace and give the final value of Num and the number of times the loop body runs.
Num ← 1
REPEAT
Num ← Num * 2
UNTIL Num > 50
Show answer
Num becomes 2, 4, 8, 16, 32, 64. After 32 the test 32 > 50 is FALSE, so the loop runs again to give 64, and then 64 > 50 is TRUE. The body runs 6 times and Num is 64.
9. What is output?
Count ← 0
FOR I ← 1 TO 10
IF I MOD 3 = 0 THEN
Count ← Count + 1
ENDIF
NEXT I
OUTPUT Count
Show answer
I MOD 3 = 0 is TRUE when I is a multiple of 3: 3, 6 and 9. Count is 3.
10. The user types 12, then 0, then 5. What is output?
Attempts ← 0
REPEAT
INPUT Mark
Attempts ← Attempts + 1
UNTIL Mark >= 1 AND Mark <= 10
OUTPUT Attempts
Show answer
12 fails (Attempts 1), 0 fails (Attempts 2), 5 is within 1 to 10 (Attempts 3). Output: 3.
11. Name two things to check on the Cambridge pages before deciding to practise Python or pseudocode for your exam.
Show answer
Check which syllabus year your exam series falls under, and check whether that syllabus and its papers expect pseudocode, a programming language or both. Your exam centre can confirm the entry details.
If you got these wrong
| What went wrong | Go to |
|---|---|
| Symbols, keywords or layout (Q3, Q5) | Use the verified 2026-2028 convention |
| Wrong values in a trace (Q1, Q2, Q4) | Trace assignment and comparison distinctly |
| Validation condition wrong (Q5, Q10) | Describe input validation |
| Loop never ends or runs the wrong number of times (Q6 to Q9) | Repair a loop termination condition |
| Unsure which notation to use (Q11) | Check the exam year before choosing notation |
Teachers on our online one-to-one Computer Science tuition can go through a set like this with you and find which habit lies behind each wrong answer.