RevisionHub

Third Form Computer Science — enter the class password

Summer Exam 2026

Programming Revision Guide

Work through each section, then test yourself with the questions below.

Questions 11, 12 & 13 · 12 marks
1

The exam writes code in OCR Exam Reference Language. It looks different from Python but does the same things. You need to be able to read and understand OCR pseudocode, but you will write your answers in Python.

Selection (IF statements)

OCR Pseudocode
if score >= 50 then print("Pass") elseif score >= 40 then print("Nearly") else print("Fail") endif
Python
if score >= 50: print("Pass") elif score >= 40: print("Nearly") else: print("Fail")
🔑
Key differences OCR uses then, elseif (one word), and endif. Python uses :, elif, and indentation only.

FOR Loops

OCR Pseudocode
for i = 0 to 4 print(i) next i
Python
for i in range(0, 5): print(i)

Both print: 0, 1, 2, 3, 4. But notice: OCR includes the end number (to 4 means up to and including 4). Python excludes it (range(0, 5) stops before 5).

WHILE Loops

OCR Pseudocode
while answer != "yes" answer = input("Try again: ") endwhile
Python
while answer != "yes": answer = input("Try again: ")
✏️ Test yourself
Question 1
What does this OCR pseudocode output? Read it carefully.
for i = 1 to 3 print(i * 10) next i
Your answer
Model answer
10
20
30

The loop runs with i = 1, 2, 3 (OCR includes the end number). Each time it prints i * 10.
Question 2
Write a Python IF statement that prints "Pass" if score is 50 or above, "Nearly" if score is 40 or above, and "Fail" otherwise.
Your answer
Model answer
if score >= 50: print("Pass") elif score >= 40: print("Nearly") else: print("Fail")
Question 3
Write a Python WHILE loop that keeps asking the user to type "yes" until they do.
Your answer
Model answer
while answer != "yes": answer = input("Try again: ")
2

An array stores multiple values in one variable. Every item has an index starting at 0.

Index01234
ValueAliBenCatDevEve

names[0] → Ali   names[4] → Eve   names.length → 5

⚠️
Why length − 1? The array above has 5 items (length = 5), but the last index is 4. Always loop from 0 to (array.length - 1).

Looping through an array

OCR Pseudocode
for i = 0 to (names.length - 1) print(names[i]) next i
✏️ Test yourself
Question 1
Using the array: scores = [8, 3, 12, 5, 9]

What is the value of scores[2]?
What is scores.length?
Your answer
Model answer
scores[2] = 12 (index 2 is the third item — indexing starts at 0)
scores.length = 5 (there are 5 items in the array)
Question 2
Write Python code to print every item in a list called colours.
Your answer
Model answer
for i in range(len(colours)): print(colours[i])
Key points: range(len(colours)) gives indices 0 to length-1 automatically.
Question 3
Why would for i = 0 to names.length cause a problem?
Your answer
Model answer
It would try to access an index that doesn't exist. If the array has 5 items (indices 0-4), names.length = 5, so it would try to access names[5] which is out of range. You must use names.length - 1.
3

Comparison Operators

SymbolMeaningExample
==Equal toif x == 5
!=Not equal toif x != 0
>Greater thanif age > 17
<Less thanif temp < 0
>=Greater than or equal toif score >= 50
<=Less than or equal toif count <= 10
🚨
= vs == One equals sign = stores a value. Two equals signs == checks if values are equal. Mixing these up is the most common mistake.

Arithmetic Operators

OCRPythonMeaningExampleResult
++Addition3 + 47
--Subtraction10 - 37
**Multiplication5 * 420
//Division10 / 33.33...
DIV//Integer division10 DIV 33
MOD%Remainder10 MOD 31
💡
DIV and MOD together — converting minutes
200 minutes: 200 DIV 60 = 3 hours, 200 MOD 60 = 20 minutes → 3h 20m

Boolean Operators: AND, OR, NOT

OperatorWhat it meansTrue when...
ANDBoth must be trueTrue AND True → True
ORAt least one trueFalse OR False → False, rest → True
NOTFlips the resultNOT True → False
✏️ Test yourself
Question 1
What is the value of each?
a) 17 DIV 5
b) 17 MOD 5
c) 200 MOD 60
Your answer
Model answer
a) 3 (17 ÷ 5 = 3 remainder 2, DIV gives the whole number)
b) 2 (17 ÷ 5 = 3 remainder 2, MOD gives the remainder)
c) 20 (200 ÷ 60 = 3 remainder 20)
Question 2
What is the difference between = and ==?
Your answer
Model answer
= is assignment — it stores a value in a variable (e.g. x = 5 sets x to 5).
== is comparison — it checks if two values are equal (e.g. if x == 5 checks if x is 5).
Question 3
A customer can enter if they are aged 18+ AND have either a ticket OR a wristband. Write this as an IF statement in Python.
Your answer
Model answer
if age >= 18 and (ticket == "yes" or wristband == "yes"): print("Allowed") else: print("Not allowed")
Key: brackets around the or condition, and/or are lowercase in Python.
4
Pattern 1

Counting items in an array

Set counter to 0. Loop through array. Check each item. Add 1 if it matches. Print counter after the loop.

OCR Pseudocode
count = 0 for i = 0 to (data.length - 1) if data[i] == 0 then count = count + 1 endif next i print(count)
Pattern 2

Selection with AND / OR

Get all inputs. Combine conditions with AND and OR using brackets. Output for both outcomes.

OCR Pseudocode
if A AND (B OR C) then print("Allowed") else print("Not allowed") endif
Pattern 3

Full algorithm from a description

Follow these steps: Input → Edge case → Calculate → Convert (DIV/MOD) → Output

OCR — Battery charger example
charge = int(input("Enter charge:")) if charge == 100 then print("full") else time = (100 - charge) * 10 hours = time DIV 60 mins = time MOD 60 print(hours, mins) endif
✏️ Test yourself
Question 1
Write Python code to count how many values in a list called temps are greater than 30.
Your answer
Model answer
count = 0 for i in range(len(temps)): if temps[i] > 30: count = count + 1 print(count)
Key: counter starts at 0, print is AFTER the loop.
Question 2
A shop gives a discount if the customer is a member AND spending over £50, OR if it is a sale day. Write Python code for this.
Your answer
Model answer
if (member == "yes" and total > 50) or saleDay == "yes": print("Discount applied") else: print("No discount")
Question 3
A runner completes a race in 475 seconds. Write Python code to convert this to minutes and remaining seconds, and print both.
Your answer
Model answer
minutes = 475 // 60 seconds = 475 % 60 print(minutes, seconds)
Result: 7 minutes, 55 seconds. // is integer division, % is remainder.
5
✗ Wrong
if x = 5
Using = to compare
✓ Right
if x == 5
Using == to compare
✗ Wrong
for i = 0 to names.length
Goes one index too far
✓ Right
for i = 0 to (names.length - 1)
Stops at the last valid index
✗ Wrong
Printing the counter inside the loop
✓ Right
Printing the counter after the loop ends
✗ Wrong
if A AND B OR C
Ambiguous logic
✓ Right
if A AND (B OR C)
Brackets make it clear
✗ Wrong
Forgetting endif, next, or endwhile
✓ Right
Every if needs endif, every for needs next
✗ Wrong
score = input("Score: ") then doing maths
✓ Right
score = int(input("Score: "))
Convert to integer first
✏️ Find and fix the errors
Question 1
This Python code has 3 errors. Find and fix them all:
count = 0 for i in range(len(scores) + 1): if scores[i] > 50 count = count + 1 print(count)
Write the corrected code
Model answer — 3 errors fixed
count = 0 for i in range(len(scores)): # Fix 1: remove + 1 (goes out of range) if scores[i] > 50: # Fix 2: missing colon count = count + 1 print(count) # Fix 3: print AFTER the loop, not inside
📋

Selection

if condition then ... elseif condition then ... else ... endif

FOR Loop

for i = 0 to 9 ... next i

WHILE Loop

while condition ... endwhile

Array Loop

for i = 0 to (arr.length-1) print(arr[i]) next i

Counting Pattern

count = 0 for i = 0 to (arr.length-1) if arr[i] == target then count = count + 1 endif next i print(count)

DIV & MOD

hours = total DIV 60 mins = total MOD 60 // Python hours = total // 60 mins = total % 60
🎯
Exam checklist — before you move on
☐ Did I use == for comparisons (not =)?
☐ Did I close every block? (endif, next, endwhile)
☐ Does my counter print outside the loop?
☐ If I used AND/OR together, did I add brackets?
☐ If the question says "hours and minutes", did I use DIV and MOD?