Every question since 2022 — with full worked answers

OCR GCSE Computer Science Paper 2Computational thinking, algorithms and programming — every question, answered

OCR GCSE Computer Science (J277) has been examined for longer than AQA 8525, so more real sittings are genuinely public. We analysed every Paper 2 (J277/02) sitting we could obtain the real question paper and mark scheme for: June 2022 (sat Friday 27 May 2022), June 2023 (sat Thursday 25 May 2023) and June 2024 (sat Tuesday 21 May 2024). OCR's own mark schemes label each series June even though the actual exam date falls in May, which we have kept exactly as OCR names it. Paper 2 is entirely about computational thinking, algorithms and programming, and it is structured differently from AQA's equivalent paper in one important way: Boolean logic, logic gates and truth tables sit on THIS paper for OCR, not on Paper 1, and SQL is genuinely tested here too. OCR calls its own pseudocode the OCR Exam Reference Language, and it has real, specific conventions that differ from AQA's pseudocode: lowercase keywords (if, then, else, endif, for, to, next, while, endwhile, do, until), a dot-property style for array and string length (array.length, not a LEN() function call), and its own random(a, b) function that is inclusive of both endpoints, unlike Python's exclusive-upper-bound randrange. Below is what each recurring question type has asked across the three sittings we have, with a complete worked answer written to the real mark scheme for each one, every paragraph explained.

OCR J27780 marks, 80 marks in all three sittings we have full papers for, split into Section A (roughly 50 minutes, no calculator, general computational thinking and Boolean logic) and Section B (roughly 40 minutes, where several questions must be answered in OCR Exam Reference Language or a high-level programming language you have studied, never structured English or a flowchart). This differs from AQA 8525's Paper 1, which is untiered at 90 marks over 2 hours with no OCR-style two-language split within one paper.1 hour 30 minutes in all three sittings we have full papers for. No calculator is allowed, and there are no additional materials required.3 sittings analysed

Questions © OCR, quoted for analysis under fair use. OCR Exam Reference Language code and program code described in our own words, not reproduced verbatim from the mark scheme. Mark scheme content translated into plain English, not copied. PrepWise is independent and not endorsed by OCR.

Q2(d)(ii) (Jun22) / Q1(d) (Jun23) / Q9(b) (Jun24)4 marksAO3 (apply)

All three sittings we have full papers for include a trace table question worth 3 to 4 marks, always built around a short OCR Exam Reference Language algorithm with a loop.

This appears once in every sitting we have full papers for: a casting-and-string-concatenation while loop generating a staff ID in June 2022, a DO UNTIL countdown loop in June 2023, and a nested IF selection structure scoring a javelin throw in June 2024.

Every Q2(d)(ii) (Jun22) / Q1(d) (Jun23) / Q9(b) (Jun24) asked — find yours3 questions · 3 full worked answers
1×asked

Complete the following trace table for the given algorithm when the surname Kofi and the year 2021 are entered

What it’s really asking

Trace an algorithm that builds a staff ID by casting a year to a string, concatenating it onto a surname, then padding the result with x characters in a while loop until it reaches 10 characters long.

What the sources actually showed — June 2022
The staff ID algorithm

An algorithm in OCR Exam Reference Language. Line 01 inputs a surname. Line 02 inputs a starting year. Line 03 sets staffID to surname concatenated with the year cast to a string using str(year). Line 04 starts a while loop that keeps running while staffID.length is less than 10. Line 05, inside the loop, appends the character x onto staffID. Line 07, after the loop, prints ID concatenated with staffID.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2022
Written to: 4/4, point marked

On line 01 surname is set to Kofi, and on line 02 year is set to 2021. Line 03 casts year to a string with str(year) and concatenates it onto surname, so staffID becomes Kofi2021, which is 8 characters long.

Why this scoresThis states the correct starting values before the loop and shows the casting on line 03 producing Kofi2021, which is the first method mark, and confirms why the loop is about to run: 8 characters is still shorter than the 10 the while condition checks for.

Because staffID.length (8) is less than 10, the loop body on line 05 runs, appending an x to make Kofi2021x, 9 characters. The condition is checked again: 9 is still less than 10, so line 05 runs a second time, making Kofi2021xx, 10 characters, at which point the while loop exits, and line 07 outputs ID Kofi2021xx as the only line of output.

Why this scoresThis correctly traces both passes through the while loop, showing staffID growing from 8 to 9 to 10 characters in the right order on line 05, and correctly stops the loop exactly when staffID.length reaches 10 rather than running an extra pass, ending on the single genuine output line.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise trace table questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Kofi2021 appearing as staffID on line 03, Kofi2021x appearing as staffID on the first pass through line 05, Kofi2021xx appearing as staffID on the second pass through line 05, and ID Kofi2021xx being the one and only output, on line 07
Evidence to deploy — 2 factsScreenshot this
  1. str(year) is OCR's own casting syntax for converting a number to a string so it can be concatenated onto text
  2. staffID.length uses OCR's dot-notation property style, not a LEN() function call
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Forgetting the loop runs twice, not once, since 8 then 9 are both still less than 10
  • Writing three x characters instead of two, which would take staffID to 11 characters and never actually satisfy the while condition at exactly 10

Full-mark self-check 0 of 3

1×asked

Complete the following trace table for the given algorithm

June 2023Tracing a DO UNTIL countdown loop Full worked answer inside

What it’s really asking

Trace a DO UNTIL loop that starts a counter at 3, prints it, decrements it by 1 each pass, and keeps going until the counter reaches -1, then prints Finished.

What the sources actually showed — June 2023
The countdown algorithm

A short algorithm in OCR Exam Reference Language. Line 01 sets start to 3. Lines 02 to 05 form a DO UNTIL loop: line 03 prints start, line 04 subtracts 1 from start, and line 05 reads UNTIL start == -1. Line 06, after the loop, prints Finished.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2023
Written to: 3/3, point marked

start is set to 3 on line 01, and because this is a DO UNTIL loop the body runs before the exit condition is ever checked, so line 03 immediately prints 3, the first output.

Why this scoresThis states the correct starting value and confirms OCR's DO UNTIL loop, like AQA's REPEAT UNTIL, always executes its body at least once before testing the UNTIL condition, which is the first method mark.

Line 04 then subtracts 1 from start each time, so start becomes 2, then 1, then 0, then -1, with line 03 printing each of those values (2, 1, 0) in turn before the loop checks start == -1. Once start actually reaches -1 the UNTIL condition is met, the loop stops without printing -1 itself, and line 06 prints Finished as the final output.

Why this scoresThis correctly traces every decrement in order (3, 2, 1, 0) with the matching print on line 03 each time, and correctly stops the loop the moment start becomes -1 without an extra printed row for -1, since the condition is checked only after line 04 runs, which is exactly the discriminator this question is testing.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise trace table questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Start set to 3 with 3 output on line 03, the values 2, 1 and 0 output on the next three passes with start correctly updated to 2, 1, 0 and -1 on the matching lines, and Finished output once on line 06
Evidence to deploy — 2 factsScreenshot this
  1. A DO UNTIL loop in OCR's Exam Reference Language behaves exactly like AQA's REPEAT UNTIL: the condition is only tested after the body has run
  2. -1 itself must never appear as an output, since the loop exits as soon as start reaches -1, before line 03 runs again
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Checking UNTIL start == -1 before the first print, which is how a WHILE loop works, not a DO UNTIL loop
  • Printing an extra row once start equals -1, when the loop should have already stopped

Full-mark self-check 0 of 3

1×asked

Complete the trace table for the algorithm when a student in year 10 throws a distance of 14.3

What it’s really asking

Trace a nested selection algorithm that awards a javelin score based on distance thrown, then doubles that score if the student is not in year 11.

What the sources actually showed — June 2024
The javelin scoring algorithm

An algorithm in OCR Exam Reference Language. Lines 01 and 02 input javelinThrow and yearGroup. Lines 03 to 09 are an IF/ELSEIF/ELSE chain setting score to 3 if javelinThrow is 20.0 or more, 2 if it is 10.0 or more, or 1 otherwise. Lines 10 to 12 are a second, independent IF: if yearGroup is not equal to 11, score is doubled. Line 13 prints The score is followed by score.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2024
Written to: 4/4, point marked

javelinThrow is set to 14.3 on line 01 and yearGroup is set to 10 on line 02. Since 14.3 is not 20.0 or more but is 10.0 or more, the elseif branch on line 05 fires, setting score to 2 on line 06.

Why this scoresThis correctly derives which branch of the first IF/ELSEIF/ELSE chain fires for a throw of 14.3, the middle band rather than the top or bottom one, giving the correct intermediate value of score as 2 on line 06, which covers the first two method marks.

Because yearGroup is 10, not 11, the second IF on line 10 is true, so line 11 doubles score from 2 to 4. Line 13 then outputs The score is 4 as the one and only line of output, with no other values printed.

Why this scoresThis correctly applies the second, independent IF that doubles the score for any year group except 11, tracing score changing from 2 to 4 on line 11, and produces the exact final output the algorithm genuinely gives, which are the remaining two method marks.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise trace table questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • javelinThrow and yearGroup set correctly on lines 01 and 02, score set to 2 on line 06, score set to 4 on line 11, and The score is 4 output once on line 13 with no additional output
Evidence to deploy — 2 factsScreenshot this
  1. The two IF statements are independent and both apply in sequence: the first decides the base score from distance, the second doubles it for any year group that is not 11
  2. 14.3 falls in the middle band, 10.0 or more but under 20.0, so it earns a base score of 2, not 1 or 3
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Doubling the score before the first IF chain has actually set it, which would double the wrong starting value
  • Adding a comma into the printed output, which the mark scheme specifically does not credit

Full-mark self-check 0 of 3

The method for every Q2(d)(ii) (Jun22) / Q1(d) (Jun23) / Q9(b) (Jun24) — same every sittingMark bands, steps, timing

What this question type rewards

The topic changes by sitting — the mark scheme never does. Learn this once, then open your question above for that sitting’s sources and a full worked answer.

  • Working through the algorithm exactly one line at a time, in the order OCR's Exam Reference Language would actually execute it
  • Writing down every intermediate value a variable takes, not just its final value, since method marks are given for correct intermediate rows
  • Matching the real number of lines and loop passes the algorithm produces, including a line where nothing changes but a row is still expected

The steps

  1. Set up one column per variable and one for Output, in the order the table header gives them
  2. Work through the algorithm line by line, only updating the variable that specific line actually changes
  3. Add a new row every time execution reaches a print statement, or loops back through a loop's start
  4. Remember OCR's DO UNTIL loop always runs its body at least once, since the condition is only checked at the end, exactly like AQA's REPEAT UNTIL
  5. Check your final row against what the algorithm would genuinely output before moving on
About 1 to 1.5 minutes per mark, so 3 to 6 minutes depending on the tariff. Trace slowly rather than in your head, since a single skipped line invalidates every row after it.
Try one now — from our question bank

What is the main purpose of a trace table?

Trace tables are worth 3 to 4 marks in every sitting we have, always built around a short OCR Exam Reference Language algorithm with a loop or a chain of selection. Practise tracing DO UNTIL loops, WHILE loops and nested IF chains until you never skip a row.

Practise trace table questions

Q2(a)(i) (Jun22) / Q4(b) (Jun23) / Q5(a) (Jun24)3 marksAO2 (apply)

Boolean logic is tested on Paper 2, not Paper 1, for OCR's own J277 specification, unlike AQA's 8525 where logic gates sit on Paper 2 (Computing concepts). All three sittings we have full papers for include at least one logic-gate or truth-table question, worth 2 to 4 marks.

This appears once in every sitting we have full papers for: drawing a three-gate circuit from a Boolean expression in June 2022, identifying two single gates from two small truth tables in June 2023, and completing a full eight-row truth table for a three-input expression in June 2024.

Every Q2(a)(i) (Jun22) / Q4(b) (Jun23) / Q5(a) (Jun24) asked — find yours3 questions · 3 full worked answers
1×asked

Complete the following logic diagram for P = (A OR B) AND NOT C by drawing one logic gate in each box

What it’s really asking

Draw the three logic gates, an OR gate, a NOT gate, and a final AND gate, needed to build the circuit for the expression P = (A OR B) AND NOT C, in the correct arrangement.

What the sources actually showed — June 2022
The logic diagram

An incomplete logic circuit with three empty gate boxes and three labelled inputs, A, B and C, feeding into a single output P. The expression the finished circuit must represent is P = (A OR B) AND NOT C.

An incomplete logic circuit with three empty gate boxes and three labelled inputs, A, B and C, feeding into a single output P. The expression the finished circuit must represent is P = (A OR B) AND NOT C.
The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2022
Written to: 3/3, point marked

The innermost bracket, (A OR B), needs an OR gate taking A and B as its two inputs, since OR is the operation joining them directly. Separately, NOT C needs its own single-input NOT gate, drawn with a small circle on its output to show inversion, taking only C as input.

Why this scoresThis correctly breaks the expression into its two independent sub-parts, an OR gate for (A OR B) and a NOT gate for NOT C, giving each gate the correct shape and the correct number of inputs, which is the first two gate marks.

The final AND gate then takes the output of the OR gate as one input and the output of the NOT gate as its other input, producing P, since the whole expression joins (A OR B) with NOT C using AND, and this AND gate must not have an inversion circle, unlike the NOT gate feeding into it.

Why this scoresThis correctly identifies that the outer-most operation, AND, is the last gate in the chain, fed by the outputs of the first two gates rather than by A, B or C directly, and correctly keeps the inversion circle only on the NOT gate, which is the third gate mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise logic gates and truth tables
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • An OR gate combining A and B, a NOT gate inverting C with a correctly drawn inversion circle, and a final AND gate combining the outputs of the first two gates to produce P, with no other gate carrying an inversion circle
Evidence to deploy — 2 factsScreenshot this
  1. Brackets in a Boolean expression map directly onto which gate's output feeds into which other gate's input
  2. Only a NOT gate carries an inversion circle in OCR's own diagram convention; AND and OR gates never do
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Putting an inversion circle on the AND gate instead of the NOT gate, which produces the wrong logic entirely
  • Feeding C directly into the final AND gate instead of feeding in the output of the NOT gate

Full-mark self-check 0 of 3

1×asked

Identify the logic gates for truth table 1 and truth table 2

June 2023Identifying a logic gate from its truth table Full worked answer inside

What it’s really asking

Work out which single logic gate, OR or AND, produced each of two given two-input truth tables, by reading the pattern of 0s and 1s in each output column.

What the sources actually showed — June 2023
Truth table 1

A two-input truth table with columns A, B and Output. The four rows read: 0,0 gives 0; 0,1 gives 1; 1,0 gives 1; 1,1 gives 1.

Truth table 2

A second two-input truth table with columns A, B and Output. The four rows read: 0,0 gives 0; 0,1 gives 0; 1,0 gives 0; 1,1 gives 1.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2023
Written to: 2/2, point marked

Truth table 1's output is 0 only when both A and B are 0, and 1 in every other case, which is exactly the pattern an OR gate produces: the output is 1 as soon as at least one input is 1.

Why this scoresThis correctly matches the given output column (0, 1, 1, 1) against the classic OR pattern rather than the AND pattern, which is the first gate-identification mark.

Truth table 2's output is 1 only on the very last row, where both A and B are 1, and 0 in every other case, which is exactly the pattern an AND gate produces: the output is 1 only when every input is 1.

Why this scoresThis correctly matches the given output column (0, 0, 0, 1) against the AND pattern, requiring both inputs true simultaneously, rather than mistaking it for an OR or another gate, which is the second gate-identification mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise logic gates and truth tables
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Truth table 1 correctly identified as an OR gate and truth table 2 correctly identified as an AND gate, based on the genuine output pattern each table shows
Evidence to deploy — 2 factsScreenshot this
  1. An OR gate's output is 0 in exactly one row, where both inputs are 0, and 1 everywhere else
  2. An AND gate's output is 1 in exactly one row, where both inputs are 1, and 0 everywhere else, the mirror image of OR
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Swapping the two answers around, since the tables look superficially similar at a glance if not read row by row
  • Naming a two-input gate as NOT, which only ever takes a single input and cannot produce either of these tables

Full-mark self-check 0 of 3

1×asked

Complete the truth table for P = (A AND B) OR C

June 2024Completing a three-input truth table Full worked answer inside

What it’s really asking

Work out the output P for all eight possible combinations of three Boolean inputs A, B and C, by evaluating (A AND B) first and then combining that result with C using OR.

What the sources actually showed — June 2024
The truth table

An empty eight-row truth table with columns A, B, C and P, listing every combination of three Boolean inputs in OCR's own row order (C changing fastest, so each pair of rows shares the same A and B and differs only in C), for the expression P = (A AND B) OR C.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2024
Written to: 4/4, point marked

Working through the eight rows in pairs that share the same A and B (with C changing from 0 to 1 within each pair), (A AND B) is 0 for the first three pairs, where A and B are 00, 01 or 10, and only 1 for the final pair, where A and B are both 1.

Why this scoresThis correctly evaluates (A AND B) once per pair of rows rather than for all eight individually, correctly identifying that only the last pair, where A equals 1 and B equals 1, makes that inner bracket true, which is the groundwork for the first two method marks.

Within each pair, the row where C is 0 keeps P equal to (A AND B) unchanged, since ORing with 0 changes nothing, while the row where C is 1 always forces P to 1, since ORing with 1 always gives 1: so the completed P column reads 0, 1, 0, 1, 0, 1, 1, 1 from top to bottom.

Why this scoresThis correctly applies the OR with C to each pair, keeping the C equals 0 row equal to (A AND B) and setting the C equals 1 row to 1 regardless, which produces the genuine completed column and covers the remaining method marks.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise logic gates and truth tables
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • The correct P value for every pair of rows in the eight-row table, one mark per pair, evaluating (A AND B) first and then combining with C using OR
Evidence to deploy — 2 factsScreenshot this
  1. A three-input truth table always needs 2 to the power of 3, 8, rows to show every possible combination
  2. OR with a 1 on either side always produces 1, which is a shortcut for half of this specific table
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Assuming the table is grouped with all four C equals 0 rows first and all four C equals 1 rows after, when OCR's actual layout alternates C every single row within each A, B pair
  • Evaluating (A AND B) OR C as if it were A AND (B OR C), which changes which rows come out as 1

Full-mark self-check 0 of 3

The method for every Q2(a)(i) (Jun22) / Q4(b) (Jun23) / Q5(a) (Jun24) — same every sittingMark bands, steps, timing

What this question type rewards

The topic changes by sitting — the mark scheme never does. Learn this once, then open your question above for that sitting’s sources and a full worked answer.

  • Getting the shape of each gate exactly right, since OCR's mark scheme marks the gate shape itself, not just a label written next to it
  • Giving a NOT gate its inversion circle and making sure no other gate has one
  • Working through a truth table or a Boolean expression input by input, one row or one bracket at a time, rather than guessing

The steps

  1. If drawing a circuit, break the expression down bracket by bracket, starting with the innermost operation
  2. Draw a NOT gate as a single-input gate with a small inversion circle on its output, never on an AND or OR gate
  3. If completing a truth table, work through every row systematically, evaluating each bracket of the expression using that row's 0s and 1s
  4. If identifying gates from a truth table, check the output column against the classic OR pattern (1 unless every input is 0) and the AND pattern (1 only if every input is 1)
  5. Double check a three-input truth table has exactly eight rows, since 2 to the power of 3 is 8
About 1 to 1.5 minutes per mark, so 2 to 6 minutes depending on the tariff.
Try one now — from our question bank

An AND gate has inputs A=1 and B=0. What is the output?

Boolean logic is tested on Paper 2 for OCR, not Paper 1, worth 2 to 4 marks in every sitting we have. Practise going bracket by bracket for circuits and expressions, and remember a three-input truth table always needs 8 rows.

Practise logic gates and truth tables

Q5(d) (Jun22) / Q2(b) (Jun23) / Q3(b) (Jun24)4 marksAO3 (refine)

All three sittings we have full papers for include a question asking you to find and fix two real logic errors in given code, worth 2 to 4 marks.

This appears once in every sitting we have full papers for: an off-by-one array index and a total reset inside the loop in June 2022, an off-by-one loop start and a reversed addition formula in June 2023, and a copy-paste variable typo plus a missing boundary check in June 2024.

Every Q5(d) (Jun22) / Q2(b) (Jun23) / Q3(b) (Jun24) asked — find yours3 questions · 3 full worked answers
1×asked

The following program, meant to total how many people are staying across nine hotel rooms, is found to contain two logic errors when tested. Describe how the program can be refined to remove these logic errors

What it’s really asking

Find and fix two bugs in a program meant to total how many people are staying in a nine-room hotel: a FOR loop that starts at 1 instead of 0, skipping room 0 entirely, and a total that gets reset to 0 inside the loop on every single pass.

What the sources actually showed — June 2022
The room-counting program

A program that should total the number of people across all nine hotel rooms, indices 0 to 8, stored in the array room. As written, it uses FOR count = 1 TO 8, so it never reads room[0], and it sets total = 0 as the very first line inside the loop body, before adding room[count], so total is wiped back to 0 on every single pass instead of accumulating.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2022
Written to: 2/2, point marked

The FOR loop currently reads FOR count = 1 TO 8, which skips index 0 entirely, so room[0]'s occupants are never counted. Changing it to FOR count = 0 TO 8 makes the loop visit every one of the nine rooms, indices 0 through 8, as the array actually holds.

Why this scoresThis correctly identifies that starting the loop at 1 misses room[0], the first genuine bug, and gives a valid corrected line that includes every real index in the array, which is the first refinement mark.

The line total = 0 is currently written inside the loop body, so it resets the running total back to zero on every single pass, throwing away everything added on previous passes. Moving total = 0 to before the loop starts means the loop can genuinely accumulate a running total across all nine rooms.

Why this scoresThis correctly identifies the second, independent bug, the reset happening on every pass rather than once, and gives a fix that keeps total accumulating rather than being wiped, which is the second refinement mark, distinct from simply moving it to the very end of the loop, which the mark scheme does not credit.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise fixing logic errors
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Changing the loop bounds so it starts at 0 rather than 1, and moving total = 0 so it only runs once, before the loop, rather than on every pass
Evidence to deploy — 2 factsScreenshot this
  1. Array room has nine elements at indices 0 to 8, so a FOR loop covering all of them must run FOR count = 0 TO 8, not 1 TO 8
  2. A running total must only be reset once, before any additions happen, or every addition except the last gets thrown away
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Fixing only the loop bounds and missing that total is still being wiped on every pass
  • Moving total = 0 to after the loop instead of before it, which is still a logic error since it discards the whole calculation

Full-mark self-check 0 of 3

1×asked

Identify two logic errors in the pseudocode algorithm. Write the refined line to correct each error

What it’s really asking

Find and fix two bugs in an algorithm meant to total every element of a 0-indexed array scores: a FOR loop that starts at 1 instead of 0, skipping the first element, and a line that overwrites scores[scoreCount] with total plus total instead of adding scores[scoreCount] onto the running total.

What the sources actually showed — June 2023
The scores-totalling algorithm

An algorithm meant to total every number in the 0-indexed array scores. Line 01 sets total to 0. Line 02 is FOR scoreCount = 1 TO scores.length - 1, which skips index 0. Line 03 is scores[scoreCount] = total + total, which overwrites the array itself with double the current total instead of adding that element onto total. Line 05 prints total.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2023
Written to: 4/4, point marked

The loop currently reads FOR scoreCount = 1 TO scores.length - 1, which never processes index 0, the array's first element. Changing line 02 to FOR scoreCount = 0 TO scores.length - 1 makes the loop cover every element the array actually contains.

Why this scoresThis correctly identifies the off-by-one loop bound as the first error, on line 02, and gives a genuinely corrected line that includes index 0, which earns the first line-number mark and the first correction mark.

Line 03 currently reads scores[scoreCount] = total + total, which overwrites the array element itself with double whatever total currently is, rather than adding that element onto the running total. Changing it to total = total + scores[scoreCount] makes the line actually accumulate each element into total, leaving the original array untouched.

Why this scoresThis correctly identifies the second, independent error, that the assignment is backwards, writing into the array instead of reading from it into total, and gives a genuinely corrected line that performs real addition rather than a self-doubling overwrite, which earns the second line-number mark and second correction mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise fixing logic errors
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Line 02 correctly identified and fixed to start the loop at 0, and line 03 correctly identified and fixed so total accumulates each array element rather than the array being overwritten with total doubled
Evidence to deploy — 2 factsScreenshot this
  1. scores.length - 1 gives the highest valid index in a 0-indexed array, so the loop must start at 0, not 1, to include every element
  2. scores[scoreCount] = total + total is a genuine logic error, not a syntax error, since it runs without crashing but produces the wrong result
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Fixing the loop bound but leaving line 03's assignment backwards, which still corrupts the array and never produces a correct total
  • Fixing the accumulation formula but forgetting scoreCount must start at 0 for the total to be fully correct

Full-mark self-check 0 of 3

1×asked

Identify the line number of the two logic errors in the algorithm and refine the code to correct each logic error

What it’s really asking

Find and fix two bugs in an algorithm meant to add two input numbers and report success or warning depending on whether the total falls between 10 and 20 inclusive: a copy-paste typo that adds num1 to itself instead of to num2, and a boundary condition that only checks the lower bound, never the upper one.

What the sources actually showed — June 2024
The success-or-warning algorithm

An algorithm that inputs num1 and num2, is meant to total them, and outputs success if the total is between 10 and 20 inclusive or warning otherwise. Line 03 reads total = num1 + num1, adding num1 to itself instead of to num2. Line 04 reads if total >= 10 then, which only checks the lower bound and never checks whether total also stays at or below 20.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2024
Written to: 4/4, point marked

Line 03 currently reads total = num1 + num1, which adds num1 to itself and never uses num2 at all. Changing it to total = num1 + num2 makes the algorithm genuinely total both of the numbers the user actually entered.

Why this scoresThis correctly identifies the copy-paste-style typo on line 03, where num2 has been replaced by a second num1, as the first error, and gives a genuinely corrected line that uses both input variables, which earns the first line-number mark and correction mark.

Line 04 currently reads if total >= 10 then, which only checks that total is at least 10 but never checks the upper limit of 20, so a total of, say, 500 would wrongly print success. Changing it to if total >= 10 and total <= 20 then makes the condition genuinely check both boundaries of the inclusive range the question describes.

Why this scoresThis correctly identifies the second, independent error, an incomplete boundary check missing its upper limit entirely, on line 04, and gives a corrected condition combining both boundaries with AND, which earns the second line-number mark and correction mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise fixing logic errors
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Line 03 correctly identified and fixed so total genuinely adds num1 and num2, and line 04 correctly identified and fixed so the condition checks both the 10 and the 20 boundary using AND, not just the lower one
Evidence to deploy — 2 factsScreenshot this
  1. A logic error like num1 + num1 runs without crashing and produces a plausible-looking number, which is exactly why it is a logic error and not a syntax error
  2. 'Between 10 and 20 inclusive' always needs two comparisons joined with AND, never a single one-sided comparison
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Fixing the addition on line 03 but leaving the boundary check on line 04 only testing the lower limit
  • Writing total >= 10 and total >= 20, which is logically impossible to combine into a sensible upper bound and never fires correctly

Full-mark self-check 0 of 3

The method for every Q5(d) (Jun22) / Q2(b) (Jun23) / Q3(b) (Jun24) — same every sittingMark bands, steps, timing

What this question type rewards

The topic changes by sitting — the mark scheme never does. Learn this once, then open your question above for that sitting’s sources and a full worked answer.

  • Pinning down the exact line number each bug is on, since marks are awarded separately for the line number and for the correction
  • Writing a corrected line that is genuinely valid code, not just a description of what should happen
  • Tracing the code by hand with a real example before committing to a fix, the same way you would for a trace table

The steps

  1. Trace the code by hand with a simple, concrete example
  2. Compare what the code actually produces against what the question says it should produce, and note exactly where the two diverge
  3. Identify the specific line number where that divergence starts, which is often earlier than where the wrong output first appears
  4. Write out a complete corrected line, matching the surrounding code's own style
  5. Re-trace your fixed version by hand to confirm it now produces the intended result
About 1 to 1.5 minutes per mark, so 2 to 6 minutes depending on the tariff.
Try one now — from our question bank

A program accepts scores between 0 and 100. Which value is an example of erroneous test data?

Finding and fixing two real logic errors comes up in every sitting we have, worth 2 to 4 marks. Practise tracing the given code by hand first, since guessing at a fix without tracing is the fastest way to lose the correction mark.

Practise fixing logic errors

Q5(c)(i) (Jun22) / Q6(e) (Jun23) / Q8(b) (Jun24)6 marksAO3 (design), AO3 (program)

All three sittings we have full papers for ask you to write a complete function or procedure from a stated specification, worth 4 to 6 marks: a price-calculating function in June 2022, a file-saving procedure in June 2023, and a position-updating function in June 2024.

This appears once in every sitting we have full papers for, always giving you the exact parameters the function or procedure must accept and the exact behaviour it must produce.

Every Q5(c)(i) (Jun22) / Q6(e) (Jun23) / Q8(b) (Jun24) asked — find yours3 questions · 3 full worked answers
1×asked

Create a function, newPrice(), that takes the number of nights and the type of room as parameters, calculates and returns the price to pay

What it’s really asking

Write a function taking nights and room as parameters that works out the total cost using the stated nightly rates, 60 pounds for a basic room, 80 pounds for a premium room, and returns that total, without validating the parameters.

What the sources actually showed — June 2022
The room pricing rules

A Basic room costs 60 pounds each night. A Premium room costs 80 pounds each night. The function newPrice() must take the number of nights and the type of room as parameters, calculate the total price, and return it, without needing to validate either parameter.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2022
Written to: 4/4, point marked

function newPrice(nights, room) if room == "basic" then price = 60 * nights elseif room == "premium" then price = 80 * nights endif return price endfunction

Why this scoresThis defines newPrice with both stated parameters, nights and room, using OCR's own function keyword and endfunction closing, which earns the header-definition mark and the two-parameters mark.

The IF/ELSEIF branch multiplies nights by the correct nightly rate for whichever room type was actually passed in, 60 for basic or 80 for premium, and the function ends with return price rather than printing it, since the specification explicitly says the function must return the calculated price, not output it.

Why this scoresThis correctly calculates the price from the parameters that were actually passed in, using the two real nightly rates the question gives, and returns rather than prints the result, which is exactly what a function, as opposed to a procedure or a plain script, needs to do, earning the calculation mark and the return mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise writing functions and procedures
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • A function header correctly named newPrice with both nights and room as parameters, a correct calculation using the two real nightly rates for whichever room type was passed in, and the calculated price returned rather than printed
Evidence to deploy — 2 factsScreenshot this
  1. A function's whole purpose is to hand a value back to whatever called it, using RETURN, which is different from a procedure, which just performs an action
  2. Basic costs 60 pounds a night and Premium costs 80 pounds a night, so the multiplication must use the rate matching whichever room string was actually passed in
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Asking for fresh input inside the function instead of using the nights and room parameters that were already passed in
  • Printing the price instead of returning it, which fails the specification even if the calculation itself is correct

Full-mark self-check 0 of 3

1×asked

Write the procedure SaveLogs()

What it’s really asking

Write a procedure taking a string of data and a filename as parameters that opens the named text file, writes the data string into it, and closes the file again.

What the sources actually showed — June 2023
The SaveLogs specification

The procedure SaveLogs() must take the string of data to be stored as a parameter, take the filename of the text file as a second parameter, and store the string of data to that text file.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2023
Written to: 6/6, point marked

procedure SaveLogs(data, filename) logFile = open(filename) logFile.writeLine(data) logFile.close() endprocedure

Why this scoresThis defines SaveLogs as a genuine procedure, not a call to one, with both stated parameters, data and filename, which earns the procedure-definition mark and the two-parameters mark.

The body opens a file using the filename that was actually passed in as a parameter, writes the data parameter into it with writeLine, and then closes the file again before the procedure ends, using each parameter for its own stated purpose rather than a hard-coded filename or fixed text.

Why this scoresThis correctly opens the file using the filename parameter specifically, rather than a fixed name, writes the data parameter into the open file, and closes it afterwards, which are the remaining marks: open using the right parameter, write using the right parameter, and close.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise writing functions and procedures
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • A genuine procedure definition, not a call, named SaveLogs with two parameters, opening a file using the filename parameter, writing the data parameter into the open file, and closing the file afterwards
Evidence to deploy — 2 factsScreenshot this
  1. A procedure differs from a function because it performs an action, saving data to a file, rather than handing a value back with RETURN
  2. Closing a file after writing to it is what actually commits the data and releases the file, which is why it earns its own separate mark
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Writing code that calls SaveLogs() rather than defining it, which earns no marks for the definition itself
  • Hard-coding a fixed filename instead of using the filename parameter that was actually passed in

Full-mark self-check 0 of 3

1×asked

Complete the function moveCharacter()

What it’s really asking

Complete a function taking direction and position as parameters that moves the character 5 places left or right, then clamps the result back into the valid range of 1 to 512 inclusive before returning the new position.

What the sources actually showed — June 2024
The moveCharacter specification

The function moveCharacter() takes the direction, left or right, and current position as parameters, changes position based on direction, subtracting 5 for left, adding 5 for right, sets position to 1 if the new position would be less than 1, sets position to 512 if the new position would be greater than 512, and returns the new position. The function header, function moveCharacter(direction, position), and the closing endfunction are already given.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2024
Written to: 6/6, point marked

if direction == "left" then position = position - 5 elseif direction == "right" then position = position + 5 endif

Why this scoresThis uses the direction and position parameters that were already passed in, without asking for any additional input, and correctly moves position by 5 in the right direction for each of the two stated cases, which earns the parameter-use mark and both movement marks.

if position < 1 then position = 1 elseif position > 512 then position = 512 endif return position This clamps position back into the valid range only after the move has already been applied, never before, since checking the bounds too early would use the character's old, not new, position, and finally returns the updated position rather than printing it.

Why this scoresThis correctly clamps position to the 1 to 512 inclusive range only after the movement has already happened, which is the order the specification requires, and returns the final position with RETURN, which are the remaining bounds-check and return marks.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise writing functions and procedures
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Correct use of both parameters with no extra input, a correct move of 5 in the direction actually passed in, position correctly clamped to 1 if it would go below 1 or to 512 if it would go above 512, and the updated position returned
Evidence to deploy — 2 factsScreenshot this
  1. The bounds check must come after the movement, not before, since it is the character's new position, not its old one, that has to stay inside 1 to 512
  2. Returning the updated position, not printing it, matches what the already-given function header and endfunction structure requires
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Checking the bounds before applying the move, which clamps the wrong, old position
  • Re-inputting direction or position inside the function instead of using the two parameters that were already passed in

Full-mark self-check 0 of 3

The method for every Q5(c)(i) (Jun22) / Q6(e) (Jun23) / Q8(b) (Jun24) — same every sittingMark bands, steps, timing

What this question type rewards

The topic changes by sitting — the mark scheme never does. Learn this once, then open your question above for that sitting’s sources and a full worked answer.

  • Defining the function or procedure header correctly first, with the right keyword and every stated parameter present, since this is its own separate mark
  • Using the parameters that were actually passed in, rather than asking for fresh input inside the function itself
  • Returning a calculated value with RETURN rather than just printing it, when the question specifically asks for a function that returns a result

The steps

  1. Write the function or procedure header first: function name(parameter1, parameter2) or procedure name(parameter1, parameter2)
  2. List every action the specification describes as its own bullet point, and make sure your code has one clearly matching line per bullet point
  3. Use the parameters directly rather than re-inputting the same data inside the function body
  4. If the specification says the function returns a value, end with a RETURN statement, not a print statement
  5. Close the definition with endfunction or endprocedure to match OCR's Exam Reference Language convention
About 1 minute per mark, so 4 to 6 minutes depending on the tariff.
Try one now — from our question bank

Which programming construct is used to make a decision based on a condition?

Writing a complete function or procedure from a stated specification is worth 4 to 6 marks in every sitting we have. Practise using the parameters you were actually given rather than asking for fresh input, and always finish a function with RETURN, not print.

Practise writing functions and procedures

Q5(a)(iii) (Jun22) / Q6(d) (Jun23) / Q9(d) (Jun24)4 marksAO3 (apply)

All three sittings we have full papers for include a genuine SQL question against a given database table, worth 3 to 4 marks.

This appears once in every sitting we have full papers for: rewriting a broken SELECT statement in June 2022, writing a SELECT with two combined WHERE conditions in June 2023, and completing a SELECT with specific field names and a WHERE clause in June 2024.

Every Q5(a)(iii) (Jun22) / Q6(d) (Jun23) / Q9(d) (Jun24) asked — find yours3 questions · 3 full worked answers
1×asked

The following SQL statement is incorrect. Rewrite the SQL statement so that it is correct

June 2022Rewriting a broken SQL SELECT statement Full worked answer inside

What it’s really asking

Fix a broken SQL statement, which uses SELECT ALL and an IF clause instead of proper syntax, so that it correctly displays every field for bookings staying more than one night from the table TblBookings.

What the sources actually showed — June 2022
The broken SQL statement and the real fields

The booking table TblBookings has fields firstName, surname, nights, room and stayComplete. The given, incorrect, statement reads SELECT ALL, FROM TblBookings, IF Nights < 1, which uses invalid keywords, ALL instead of a real field list or star, and IF instead of WHERE, and also states the wrong comparison direction for staying more than one night.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2022
Written to: 4/4, point marked

SELECT firstName, surname, nights, room, stayComplete FROM TblBookings WHERE nights > 1

Why this scoresThis replaces the invalid SELECT ALL with a real field list covering every column in the table, an equally valid alternative to SELECT *, keeps FROM TblBookings correct as already given, and replaces the invalid IF clause with a genuine WHERE clause, which together earn the field-list, FROM and WHERE-keyword marks.

The condition itself is nights > 1, not nights < 1 as the broken version stated, since the question specifically asks for bookings staying more than one night, and more than one means strictly greater than 1, not less than 1.

Why this scoresThis correctly reverses the broken version's comparison direction to match what the question actually asks for, staying more than one night rather than fewer than one night, which is the final, genuinely correct-logic mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise SQL questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • A genuine field list or SELECT * replacing the invalid SELECT ALL, FROM TblBookings kept correct, WHERE replacing the invalid IF keyword, and the condition itself correctly reading nights greater than 1, not less than 1
Evidence to deploy — 2 factsScreenshot this
  1. SQL's three core clauses are SELECT, which fields, FROM, which table, and WHERE, which rows, always in that order
  2. More than one night translates to nights > 1, since a stay of exactly one night should not be included
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Keeping the broken IF keyword instead of replacing it with WHERE, which is not valid SQL
  • Writing nights < 1, which is the exact comparison direction the broken version wrongly used, filtering for almost no bookings instead of the ones actually wanted

Full-mark self-check 0 of 3

1×asked

Write an SQL statement to display the sensor IDs of the door sensors that have been triggered for more than 20 seconds

What it’s really asking

Write a SELECT statement against the events table that displays only the SensorID field, filtered to rows where SensorType is Door and Length is more than 20, combining both conditions.

What the sources actually showed — June 2023
The events table

A database table called events with fields Date, SensorID, SensorType and Length, storing a log entry each time a sensor is triggered, including door, motion and window sensor events with their trigger length in seconds.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2023
Written to: 3/3, point marked

SELECT SensorID FROM events WHERE Length > 20 AND SensorType = "Door"

Why this scoresThis selects only the field the question actually asks for, SensorID, states the correct table name events, and combines both real conditions, the sensor type being Door and the trigger length exceeding 20 seconds, with AND, since a row must satisfy both criteria at once, which earns all three marks.

Writing the two conditions in either order is equally valid, as long as both are joined with AND rather than OR, since a query asking for door sensors specifically that were also triggered for more than 20 seconds needs every returned row to satisfy both facts simultaneously, not just one of them.

Why this scoresThis confirms that AND, not OR, is the correct join between the two conditions, since OR would also wrongly return every door sensor event regardless of length, and every long event regardless of sensor type, which is the reasoning behind the WHERE-clause mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise SQL questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • SensorID selected as the only displayed field, the correct table name events, and a WHERE clause combining Length > 20 and SensorType = Door with AND, in either order
Evidence to deploy — 2 factsScreenshot this
  1. Door sensors triggered for more than 20 seconds is genuinely two separate conditions that must both be true at once, which always means AND in SQL, never OR
  2. String values like Door need quotation marks in a WHERE clause, unlike numeric values like 20
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Joining the two conditions with OR instead of AND, which would also return every long trigger of any sensor type
  • Selecting every field with SELECT * when the question specifically asks only for the sensor IDs

Full-mark self-check 0 of 3

1×asked

Complete the SQL statement to show the Student ID and team name of all students who are in year group 11

June 2024Completing a partly given SQL SELECT statement Full worked answer inside

What it’s really asking

Complete a partially given SELECT statement so it displays TeamName alongside the already-shown StudentID field, from the correct table, filtered to rows where YearGroup equals 11.

What the sources actually showed — June 2024
The TblResult table and the given SQL fragment

The database table TblResult has fields StudentID, YearGroup, TeamName and Time, storing each student's 100m race result. The statement SELECT StudentID, ... is already partly given, with three blank spaces left to complete: the rest of the field list, the FROM clause, and the WHERE clause.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2024
Written to: 4/4, point marked

SELECT StudentID, TeamName FROM TblResult WHERE YearGroup = 11

Why this scoresThis completes the already-given field list with TeamName, the second field the question specifically asks for, names the correct table TblResult exactly as spelled in the database, and filters with WHERE YearGroup = 11, which together earn the field, table and condition marks.

TeamName is added onto the field list rather than replacing StudentID, since the question asks for both the Student ID and the team name displayed together, and the table name must be spelled exactly TblResult, not TblResults or any other variation, since SQL table names must match precisely.

Why this scoresThis confirms both required fields, StudentID, already given, and TeamName, newly added, appear together, and that the table name is copied exactly as it appears in the database, which is what the table-name mark specifically requires.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise SQL questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • TeamName correctly added to the already-given StudentID field list, the table named exactly TblResult, and a WHERE clause correctly filtering to YearGroup = 11
Evidence to deploy — 2 factsScreenshot this
  1. The question already gives SELECT StudentID, so the completed statement only needs TeamName added to that same field list, not a fresh SELECT
  2. Table and field names in SQL must be spelled exactly as the database defines them, including capitalisation conventions like TblResult
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Selecting every field with * instead of the two specifically asked for
  • Misspelling the table name as TblResults, with an extra s, which the mark scheme specifically penalises

Full-mark self-check 0 of 3

The method for every Q5(a)(iii) (Jun22) / Q6(d) (Jun23) / Q9(d) (Jun24) — same every sittingMark bands, steps, timing

What this question type rewards

The topic changes by sitting — the mark scheme never does. Learn this once, then open your question above for that sitting’s sources and a full worked answer.

  • Getting the three real clauses in the right order: SELECT the fields, FROM the table, WHERE the condition
  • Selecting only the fields the question actually asks for, or using SELECT * only when every field is genuinely needed
  • Writing a condition that combines the given criteria correctly, using AND when every condition must be true at once

The steps

  1. Identify exactly which fields the question wants displayed, and list them after SELECT, separated by commas
  2. Write FROM followed by the exact table name given
  3. Write WHERE followed by every condition the question states, joined with AND if more than one must all be true
  4. Check field names, table names and any quoted text values are spelled exactly as given
  5. Reread the finished statement against the question's own wording to confirm it filters and displays exactly what was asked for
About 1 minute per mark, so 3 to 4 minutes depending on the tariff.
Try one now — from our question bank

Which SQL keyword is used to choose which columns to retrieve from a database table?

A real SQL SELECT statement is tested in every sitting we have, worth 3 to 4 marks. Practise the three-clause order, SELECT, FROM, WHERE, and combining multiple conditions with AND.

Practise SQL questions

Q5(b)(i) (Jun22) / Q5(b) (Jun23) / Q9(c)(i) (Jun24)5 marksAO2/AO3 (apply and design)

All three sittings we have full papers for test input validation, worth 4 to 6 marks: writing a full validation program checking three separate rules in June 2022, naming and explaining two validation methods in prose in June 2023, and writing a validation check with a compound boundary condition in June 2024.

This appears once in every sitting we have full papers for, always tied to the specific rules given in that question rather than validation in the abstract.

Every Q5(b)(i) (Jun22) / Q5(b) (Jun23) / Q9(c)(i) (Jun24) asked — find yours3 questions · 3 full worked answers
1×asked

Complete the following program to validate the inputs

What it’s really asking

Write a program that checks three separate rules on a hotel booking, firstName and surname are not empty, room is basic or premium, nights is between 1 and 5 inclusive, and outputs ALLOWED only if all three pass, or NOT ALLOWED if any one fails.

What the sources actually showed — June 2022
The booking validation rules

firstName and surname must not be empty. room must be either basic or premium. nights must be between 1 and 5 inclusive. If any of the three checks fail, the program must output NOT ALLOWED; if all three pass, it must output ALLOWED. The four input lines, firstName, surname, room, nights, are already given.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2022
Written to: 5/5, point marked

valid = True if firstName == "" or surname == "" then valid = False endif if room != "basic" and room != "premium" then valid = False endif if nights < 1 or nights > 5 then valid = False endif

Why this scoresThis checks all three stated rules independently, using a presence check on firstName and surname that rejects an empty string, a look-up-style check that room is genuinely one of the two allowed values, and a range check on nights covering both the lower and upper bound, which together earn the three individual-check marks.

if valid then print("ALLOWED") else print("NOT ALLOWED") endif The final IF only prints ALLOWED if all three checks passed and valid never got set to False, and prints NOT ALLOWED the moment any single check fails, so a booking that fails only the nights check still correctly gets NOT ALLOWED, not a false ALLOWED.

Why this scoresThis correctly makes the final output depend on every single check having passed, not just the most recently checked one, which is exactly what the mark scheme's output marks require: NOT ALLOWED whenever any one of the three checks fails, and ALLOWED only when all three genuinely pass.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise input validation questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • A genuine attempt at all three stated checks, presence check on the names, look-up check on room, range check on nights covering both 1 and 5 inclusive, and correct output logic that only prints ALLOWED when every check has genuinely passed
Evidence to deploy — 2 factsScreenshot this
  1. Between 1 and 5 inclusive means both 1 and 5 themselves count as valid, so the reject condition must be nights < 1 or nights > 5, not <= or >=
  2. Combining three independent checks that must all pass for a valid outcome uses a single valid flag set to False by any failing check, rather than three separate nested IFs
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Using nights <= 1 or nights >= 5 for the range check, which would wrongly reject the two valid boundary values themselves
  • Printing ALLOWED as soon as one check passes, rather than only once every check has passed

Full-mark self-check 0 of 4

1×asked

Identify two methods of validation and explain how they can be used on this game

What it’s really asking

Name two real validation techniques and explain, specifically for this addition game which asks the player to add two random whole numbers between 1 and 10, how each one would actually be applied to the player's typed answer.

What the sources actually showed — June 2023
The addition game rules

The game asks the player three addition questions, each adding two random whole numbers between 1 and 10 inclusive, adds 1 to the player's score for each correct answer, and displays the final score at the end. The player's typed answer needs validating before it is checked against the correct sum.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2023
Written to: 6/6, point marked

Range check: this checks the player's answer falls between sensible upper and lower limits, for example between 2, the smallest possible sum of two numbers from 1 to 10, and 20, the largest possible sum, rejecting an answer like -5 or 500 that could never genuinely be correct for this game.

Why this scoresThis names a real validation technique, range check, and ties its use specifically to this game's own real limits, 2 to 20, the true minimum and maximum possible sums, rather than a generic range with no connection to the addition rules given, which earns the method mark and both use marks.

Type check: this checks the player's answer is actually a whole number, an integer, rejecting a non-numeric answer such as the word seven typed out or a decimal like 4.5, since the two random numbers being added are always whole numbers between 1 and 10, so any genuinely correct answer must also be a whole number.

Why this scoresThis names a second, genuinely different validation technique, type check, and explains its use specifically for this game, rejecting non-integer input, rather than repeating the range check under a different name, which earns the second method mark and its two use marks.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise input validation questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Two genuinely different validation methods named correctly, each with an explanation of how it applies specifically to the addition game's own real rules, not a generic description unconnected to the game
Evidence to deploy — 2 factsScreenshot this
  1. The smallest possible sum of two numbers from 1 to 10 is 2, and the largest is 20, so a genuine range check for this specific game uses those two real limits
  2. A type check and a range check are two independent techniques: a value can pass one and still fail the other
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Naming a validation method but only describing what it means in general, without tying it to this specific game's real numbers
  • Naming two methods that are really the same idea under different names, such as range check and boundary check used to describe an identical rule twice

Full-mark self-check 0 of 3

1×asked

Write an algorithm to take the height jumped as input, output VALID or NOT VALID depending on the height input

What it’s really asking

Write an algorithm that inputs a high jump height in centimetres and outputs VALID only if it falls between 40.0 and 180.0 inclusive, or NOT VALID otherwise.

What the sources actually showed — June 2024
The high jump validation rule

The height jumped is entered in centimetres and must be between 40.0 and 180.0 inclusive. The algorithm must take the height as input and output VALID or NOT VALID depending on whether it satisfies that range.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2024
Written to: 4/4, point marked

h = input("Enter height jumped") if h >= 40 and h <= 180 then print("valid") else print("not valid") endif

Why this scoresThis inputs and stores the height, then checks both the lower boundary, 40 or more, and the upper boundary, 180 or less, in a single combined condition using AND, which earns the input mark and both boundary-check marks.

Because the condition uses >= and <=, both 40.0 and 180.0 themselves are correctly treated as valid, matching the question's own wording of inclusive, and the output correctly flips to valid only when the height genuinely satisfies both boundaries at once, with not valid printed for anything outside that range, including a negative height or an impossibly large one.

Why this scoresThis confirms the inclusive boundary wording has been correctly translated into >= and <= rather than the stricter > and <, and that the correct output prints for exactly the range the question describes, which is the discriminator the final output mark rewards.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise input validation questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • The height correctly input and stored, both the minimum, 40, and maximum, 180, boundaries checked, and VALID or NOT VALID correctly output depending on whether the height genuinely satisfies both boundaries
Evidence to deploy — 2 factsScreenshot this
  1. Between 40.0 and 180.0 inclusive always means >= 40 and <= 180, since both limits themselves must count as valid
  2. A single combined AND condition checking both boundaries at once is functionally identical to two separate nested IFs, and the mark scheme accepts either
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Using > and < instead of >= and <=, which would wrongly reject a height of exactly 40.0 or exactly 180.0
  • Checking only one of the two boundaries, which would wrongly accept an impossibly large or negative height

Full-mark self-check 0 of 3

The method for every Q5(b)(i) (Jun22) / Q5(b) (Jun23) / Q9(c)(i) (Jun24) — same every sittingMark bands, steps, timing

What this question type rewards

The topic changes by sitting — the mark scheme never does. Learn this once, then open your question above for that sitting’s sources and a full worked answer.

  • Checking every single rule the question actually states, not just the most obvious one
  • Using the exact boundary the question describes, including whether a limit itself counts as valid, inclusive, or not
  • Naming a real, specific validation technique, range check, length check, presence check, format check, type check, rather than a vague description

The steps

  1. List every distinct rule the question states as its own checklist item
  2. Decide which named validation technique, range, length, presence, type, format, matches each rule
  3. Write or describe the Boolean condition for each rule, paying close attention to inclusive versus exclusive boundary wording
  4. Combine multiple rules correctly, AND when every rule must pass, OR when failing any one rule is enough to reject the input
  5. Check your finished answer against a genuinely valid example and a genuinely invalid example by hand
About 1 to 1.2 minutes per mark, so 4 to 7 minutes depending on the tariff.
Try one now — from our question bank

A program asks the user to enter a score between 1 and 10. Which validation check should be used to ensure the number is within this range?

Validating input against a set of stated rules is worth 4 to 6 marks in every sitting we have. Practise naming a real, specific technique for every rule and always checking whether a boundary itself counts as valid.

Practise input validation questions

Q4(c) (Jun22) / Q5(c) (Jun23) / Q9(f) (Jun24)6 marksAO3 (design), AO3 (program)

All three sittings we have full papers for include a longer algorithm-writing question worth exactly 6 marks, always combining a loop with a running calculation: totalling and averaging a user-chosen quantity of numbers in June 2022, a three-round addition quiz in June 2023, and finding the highest-scoring team from sentinel-controlled input in June 2024.

This appears once in every sitting we have full papers for, and it is consistently one of the single highest-tariff pieces of program-writing on the paper alongside the function or procedure cluster, always worth 6 marks.

Every Q4(c) (Jun22) / Q5(c) (Jun23) / Q9(f) (Jun24) asked — find yours3 questions · 3 full worked answers
1×asked

Write an algorithm to ask the user to input the quantity of numbers, repeatedly take a number as input until that many numbers have been entered, calculate and output the total, and calculate and output the average

What it’s really asking

Write an algorithm that first asks how many numbers to add up, then loops that many times taking a number each pass and adding it to a running total, then outputs both the total and the average once the loop finishes.

What the sources actually showed — June 2022
The specification

Ask the user to input the quantity of numbers they want to enter and read this as input. Repeatedly take a number as input, until the quantity of numbers the user input has been entered. Calculate and output the total of these numbers. Calculate and output the average of these numbers.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2022
Written to: 6/6, point marked

num = input("Enter how many numbers") total = 0 for x = 1 to num temp = input("Enter a number") total = total + temp next x

Why this scoresThis inputs the quantity with a clear message and stores it, initialises total to 0 before the loop starts, not inside it, and uses a FOR loop controlled by that quantity, correctly repeating exactly num times and adding each newly input number onto the running total on every pass, which earns the input, repetition and accumulation marks.

print(total) print(total / num) Both outputs happen only after the loop has fully finished, using the genuinely final value of total rather than a value from partway through the loop, and the average is calculated by dividing that final total by num, the same quantity that controlled how many numbers were actually entered.

Why this scoresThis correctly waits until the loop has completed before calculating and outputting either result, uses the real final total rather than an intermediate one, and divides by the same num that controlled the loop, which is exactly what a genuine average calculation needs, earning the average and output marks.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise iteration and running-calculation questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • An input step with a message that stores the quantity, total initialised to 0 before the loop, the loop correctly repeating that many times using the input quantity, the running total correctly accumulating each new number, and both total and average correctly calculated and output after the loop finishes
Evidence to deploy — 2 factsScreenshot this
  1. total must be initialised once, before the loop, or it would either not exist yet or get wiped on every pass
  2. Dividing total by num, the same variable that controlled the loop, guarantees the average is genuinely correct regardless of how many numbers the user chose to enter
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Initialising total inside the loop, which wipes it back to 0 on every single pass, the same bug this paper tests directly as a logic error elsewhere
  • Calculating the average using a fixed number instead of the actual quantity num the user entered

Full-mark self-check 0 of 4

1×asked

Write an algorithm to play this game

What it’s really asking

Write an algorithm that asks the player three addition questions, each adding two random whole numbers between 1 and 10, adds 1 to a running score for each correct answer, and displays the final score once all three rounds are done.

What the sources actually showed — June 2023
The addition game rules

The player is asked 3 addition questions. Each question asks the player to add together two random whole numbers between 1 and 10 inclusive. If the player gets the correct answer, 1 is added to their score. At the end of the game their score is displayed.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2023
Written to: 6/6, point marked

score = 0 for count = 1 to 3 num1 = random(1, 10) num2 = random(1, 10) ans = input("What is " + num1 + " + " + num2 + "?") if ans == num1 + num2 then score = score + 1 endif next count

Why this scoresThis initialises score to 0 before the loop, uses a FOR loop that runs exactly three times matching the three questions the specification asks for, generates two genuinely new random numbers between 1 and 10 on every single pass, and correctly checks the player's answer against the real sum, adding 1 to score only on a correct answer, which earns the initialisation, repetition, random-generation and scoring marks.

print(score) The score is output once, after the loop has run all three times, rather than after every individual question, since the specification asks for the final score to be displayed at the end of the game, not after each round.

Why this scoresThis correctly places the final output after the loop has completed, using the genuinely accumulated score rather than an intermediate value from partway through the three rounds, which is exactly what the specification's own wording, at the end of the game, requires, earning the final output mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise iteration and running-calculation questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • score initialised to 0 before the loop, a loop repeating exactly three times, two genuinely new random numbers generated each round, the player's input checked against the real sum with 1 added to score on a correct answer, and score output once at the end
Evidence to deploy — 2 factsScreenshot this
  1. random(1, 10) is OCR's own Exam Reference Language random-number function, inclusive of both 1 and 10, unlike Python's randrange which excludes its upper bound
  2. Generating new random numbers inside the loop, not before it, is what makes each of the three questions genuinely different
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Generating the two random numbers once before the loop and reusing the same pair for all three questions
  • Outputting score after every single question instead of once, at the end, after all three rounds

Full-mark self-check 0 of 4

1×asked

Write an algorithm to prompt for team names and scores until stop is entered, calculate which team has the highest score, and output the winning team name and score

What it’s really asking

Write an algorithm that keeps asking for a team name and score until the user types stop, keeps track of the highest score seen so far and which team it belongs to, and outputs the winning team's name and score once input stops.

What the sources actually showed — June 2024
The sports day specification

Prompt the user to enter a team name and score, or to enter stop to stop entering new teams. Repeatedly take team names and scores as input until the user enters stop. Calculate which team has the highest score. Output the team name and score of the winning team in an appropriate message.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2024
Written to: 6/6, point marked

highscore = 0 team = "" while team != "stop" team = input("enter team name") score = input("enter score") if score > highscore then highscore = score highteam = team endif endwhile

Why this scoresThis uses a WHILE loop controlled by a sentinel value, genuinely repeating for as many teams as the user chooses to enter rather than a fixed count, inputs both a team name and a score on every pass and stores them separately, and compares each new score against the highest one seen so far, updating both highscore and highteam together whenever a new highest score is found, which earns the sentinel-loop, input and highest-tracking marks.

print(highscore) print(highteam) Both the winning score and the winning team name are output only once the WHILE loop has genuinely finished, meaning the user has typed stop, using the final accumulated highscore and highteam rather than values from partway through entering the teams.

Why this scoresThis correctly waits until every team has been entered before outputting a result, since the true highest score cannot be known until the very last team has been checked, and outputs both required pieces of information, the team name and its score, together, which is the final output mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise iteration and running-calculation questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • A genuine sentinel-controlled loop that repeats until stop is entered, a team name and score input and stored on every pass, the highest score correctly tracked and updated alongside its matching team name, and both the winning team name and score output once the loop has finished
Evidence to deploy — 2 factsScreenshot this
  1. A sentinel-controlled WHILE loop is the right structure here because the number of teams is not known in advance, unlike the fixed three rounds of the addition game question
  2. highteam must be updated in the very same IF branch as highscore, on the same pass, or the two could end up referring to different teams
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Using a FOR loop with a fixed number of repeats instead of a WHILE loop controlled by the sentinel value stop
  • Updating highscore without also updating highteam in the same branch, which would leave the winning name pointing at the wrong team

Full-mark self-check 0 of 4

The method for every Q4(c) (Jun22) / Q5(c) (Jun23) / Q9(f) (Jun24) — same every sittingMark bands, steps, timing

What this question type rewards

The topic changes by sitting — the mark scheme never does. Learn this once, then open your question above for that sitting’s sources and a full worked answer.

  • Getting the loop's controlling condition right, whether it is a fixed count, a user-chosen quantity, or a sentinel value like stop
  • Initialising any running total, count or highest-value tracker before the loop starts, not inside it, so it is not reset every pass
  • Handling every distinct outcome the specification lists, including calculating a final result, an average, a winner, after the loop has actually finished

The steps

  1. Identify what controls the loop: a fixed number of repeats, a quantity the user inputs first, or a sentinel value the user eventually types to stop
  2. Initialise any variable that will accumulate across passes, a total, a count, a highest-so-far, before the loop begins
  3. Inside the loop, take the input and update the accumulating variable exactly once per pass
  4. After the loop ends, calculate any final result that depends on the whole set of inputs, such as an average or a winner
  5. Output every result the specification asks for, in an appropriate message
About 1 minute per mark, so roughly 6 minutes. This is usually one of the longer questions on the paper, so plan your time rather than rushing it.
Try one now — from our question bank

Which type of loop is best used when you know exactly how many times the loop should repeat?

This 6-mark iteration-and-calculation question appears in every sitting we have, always one of the highest tariffs on the paper. Practise initialising your accumulator before the loop and only outputting a final result once the loop has genuinely finished.

Practise iteration and running-calculation questions

Q3(a) (Jun22) / Q3(c)(i) (Jun23) / Q3(c)(i) (Jun24)3 marksAO1/AO2 (recall and apply)

All three sittings we have full papers for test genuine understanding of how a sorting or searching algorithm works, worth 2 to 3 marks, though the exact skill, completing a merge sort, comparing two sorts, or tracing a binary search, varies each time.

This appears once in every sitting we have full papers for: completing every step of a merge sort by hand in June 2022, stating one real difference between insertion sort and bubble sort in June 2023, and tracing a binary search on a given seven-item data set in June 2024.

Every Q3(a) (Jun22) / Q3(c)(i) (Jun23) / Q3(c)(i) (Jun24) asked — find yours3 questions · 3 full worked answers
1×asked

Complete the merge sort of the data by showing each step of the process

What it’s really asking

Show the real steps a merge sort takes on the eight-number list 45, 12, -99, 100, -13, 0, 17, -27: merging the eight single-item lists into sorted pairs of two, then into sorted groups of four, then into one final sorted list of eight.

What the sources actually showed — June 2022
The unsorted list

A list of eight positive and negative numbers, already split into eight individual one-number lists as the question's first step: 45, 12, -99, 100, -13, 0, 17, -27.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2022
Written to: 3/3, point marked

Merging the eight single-number lists into pairs, in the original order they appear, gives four sorted lists of two: 12 and 45 merge into [12, 45], -99 and 100 merge into [-99, 100], -13 and 0 merge into [-13, 0], and -27 and 17 merge into [-27, 17].

Why this scoresThis correctly merges each adjacent pair of single-item lists into a genuinely sorted pair, comparing the two original numbers correctly even where one or both are negative, which is the first method mark, merging into correctly sorted lists of size 2.

Merging those four pairs into two sorted lists of four gives [-99, 12, 45, 100] and [-27, -13, 0, 17], comparing across each pair's smallest and largest values correctly, and merging those two lists of four into the one final sorted list of eight gives -99, -27, -13, 0, 12, 17, 45, 100.

Why this scoresThis correctly continues the merge sort's real process, combining the size-2 lists into size-4 lists and finally into the one fully sorted size-8 list, keeping every negative number correctly ordered before every positive one, which is the remaining two method marks.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise sorting and searching questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • Merging into correctly sorted lists of size 2, then correctly merging those into sorted lists of size 4, then correctly merging those into the one final sorted list of size 8
Evidence to deploy — 2 factsScreenshot this
  1. Merge sort only ever compares and merges adjacent lists, doubling their size each round, never sorting the whole list in place in one pass
  2. Negative numbers sort exactly like positive numbers, in ascending order, so -99 comes before -27, which comes before -13
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Sorting the final list correctly but skipping the intermediate size-2 and size-4 merge steps the question specifically asks to see
  • Merging lists in the wrong original order, rather than the adjacent pairs the initial split actually produced

Full-mark self-check 0 of 3

1×asked

Describe one difference between an insertion sort and a bubble sort

What it’s really asking

State one genuine, specific difference in how an insertion sort and a bubble sort actually move data, rather than a vague claim that one is better than the other.

What the sources actually showed — June 2023
The insertion sort algorithm

A pseudocode insertion sort on the array names, which moves through the array from the second element onwards, shifting each value left into its correct position relative to the already-sorted values before it.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2023
Written to: 2/2, point marked

An insertion sort builds up a sorted section at the start of the array and inserts each new value directly into its correct position within that already-sorted section, moving other values along to make room, whereas a bubble sort repeatedly compares neighbouring pairs of values and swaps them if they are in the wrong order, without ever inserting a value directly into a specific position.

Why this scoresThis names one genuine mechanism for each sort within a single answer, insertion sort inserts a value into a correct position within a growing sorted section, bubble sort only ever swaps adjacent pairs, which earns both of the mark scheme's two marks, one for a real insertion sort mechanism and one for a real bubble sort mechanism, rather than a vague efficiency claim with no real mechanism described for either.

A related, equally valid way to state the same real difference is that insertion sort's sorted section grows from the start of the array outward with every pass, while a bubble sort's largest unsorted value instead gets bubbled up to the end of the array on each full pass, which is a different real mechanism, not just different wording for an identical process.

Why this scoresThis gives an equally valid pair of phrasings for the same two marks, which end of the array becomes sorted first for each algorithm, and by what real mechanism, showing there is more than one correct way to name both sorts' real mechanisms rather than just different wording for an identical process.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise sorting and searching questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • One genuine, specific mechanical difference between how insertion sort and bubble sort move data, such as insertion sort inserting values into a growing sorted section versus bubble sort only ever swapping adjacent pairs
Evidence to deploy — 2 factsScreenshot this
  1. Insertion sort's sorted section grows from the front of the array; bubble sort's sorted section, the largest values, grows from the back
  2. Bubble sort is slower by itself, with no mechanism given, is not specific enough to earn this mark
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Giving only a vague efficiency claim, bubble sort is worse, with no real mechanism described
  • Describing a similarity, both use loops, both compare values, when the question specifically asks for a difference

Full-mark self-check 0 of 2

1×asked

Show how a binary search will be used to find the number 10 in the following data set: 1, 2, 5, 6, 7, 10, 20

What it’s really asking

Trace a binary search for the number 10 across the seven-item sorted list 1, 2, 5, 6, 7, 10, 20, showing which middle value gets picked and discarded on each real comparison until 10 is found.

What the sources actually showed — June 2024
The sorted data set

A sorted, seven-item list of numbers: 1, 2, 5, 6, 7, 10, 20. A binary search must find the number 10 within it.

The real data and numbers, recreated in our own layout — never the exam board's own artwork or photos.
The full worked answer — June 2024
Written to: 3/3, point marked

The middle value of the full seven-item list is 6, the fourth item. Since the target, 10, is larger than 6, the entire left half of the list, 1, 2, 5, is discarded, keeping only the right half, 7, 10, 20.

Why this scoresThis correctly picks out the genuine middle value of the real seven-item list, 6, and correctly discards only the left half since 10 is larger than 6, which is the first two method marks, both tied to the actual data given rather than a generic description.

The middle value of the remaining three-item list, 7, 10, 20, is 10, which matches the target exactly, so the search ends here, having found 10 in two comparisons.

Why this scoresThis correctly identifies that the second middle value picked from the real remaining list is 10 itself, ending the search on a genuine match rather than continuing to halve the list further once the target has already been found, which is the third method mark.

Could you have written this? Every fact in this answer is drilled in our quizzes — the writing is the easy part once the evidence is automatic.

Practise sorting and searching questions
Worked answer · PrepWise · prepwise.ukOur own writing — aimed at the real mark scheme, never copied

What the mark scheme rewarded

  • The correct middle value, 6, picked from the real given list, the correct half, the left half, since 10 is larger than 6, discarded, and the correct second middle value, 10, picked from the real remaining list, matching the target
Evidence to deploy — 2 factsScreenshot this
  1. A binary search always compares against the actual middle value of whatever range remains, not a fixed position, so which value is picked changes as the range shrinks
  2. This particular seven-item list finds 10 in exactly two comparisons, since the second middle value picked happens to be the target itself
PrepWise · prepwise.ukDrill these facts in the app

Traps examiners saw

  • Picking the wrong middle value when a remaining list has an even number of items, though this specific list stays an odd length throughout its own trace
  • Continuing to compare after the target has already been found on the second comparison

Full-mark self-check 0 of 3

The method for every Q3(a) (Jun22) / Q3(c)(i) (Jun23) / Q3(c)(i) (Jun24) — same every sittingMark bands, steps, timing

What this question type rewards

The topic changes by sitting — the mark scheme never does. Learn this once, then open your question above for that sitting’s sources and a full worked answer.

  • Working through the algorithm's real steps on the actual data given, not describing the algorithm in the abstract
  • Getting sorting and searching terminology exactly right, since a vague description without the word in order is not enough for a linear search
  • Naming a genuine difference or similarity, not two ways of saying the same thing about both algorithms

The steps

  1. If tracing on real data, work through the actual numbers given, one comparison or one merge step at a time
  2. If comparing two algorithms, pick one real difference in how they move data rather than a vague efficiency claim alone
  3. If describing a search, be precise about the order values are checked in, and what the algorithm does when the target genuinely is not present
  4. Double check any precondition the algorithm depends on, such as a binary search needing already-sorted data
  5. Reread your answer against the actual data set or algorithm given, not a generic textbook description
About 1 to 1.5 minutes per mark, so 2 to 4.5 minutes depending on the tariff.
Try one now — from our question bank

Which of the following is a requirement before binary search can be used?

Understanding how sorting and searching algorithms actually work, not just naming them, is tested in every sitting we have, worth 2 to 3 marks. Practise working through real data by hand rather than reciting a textbook description.

Practise sorting and searching questions
Across the sittings we analysed

What is guaranteed to come up, and what genuinely varies

Across the three sittings we have full papers for, Paper 2's overall structure and total marks, 80, never changed, and the same eight question archetypes appear in every single sitting, though the specific rules, data or algorithm tested within each archetype is different every time.

0

Not seen on Paper 2 in the three sittings we have full papers for

Systems architecture, CPU components or the fetch-decode-execute cycle · Primary and secondary storage, including RAM, ROM and units of data · Wired and wireless networks, network topologies or protocols · Network security threats and prevention methods · Systems software, including operating systems and utility software · Ethical, legal, cultural and environmental impacts of digital technology

These topics are genuinely part of the OCR J277 specification, but they belong to Paper 1 (J277/01, Computer systems), not Paper 2, and did not appear as a standalone question on any Paper 2 sitting we analysed, so do not build your Paper 2 revision plan around them.

Common questions

Before you revise

Does Paper 2 have the same structure every year?

Yes, in all three sittings we have full papers for. Every sitting totalled 80 marks in 1 hour 30 minutes, with no calculator allowed, split into Section A, roughly 50 minutes of general computational thinking and Boolean logic, and Section B, roughly 40 minutes, where several questions must be answered in OCR's own Exam Reference Language or a high-level programming language you have studied, never structured English or a flowchart. Always check your own paper's front cover to confirm, since OCR can make real changes in any future series.

What is the OCR Exam Reference Language, and how is it different from AQA's pseudocode?

It is OCR's own official name for the pseudocode style used across its question papers and mark schemes. Based on the three real sittings we analysed, it uses lowercase keywords (if, then, else, endif, for, to, next, while, endwhile, do, until, function, endfunction, procedure, endprocedure), a dot-property style for array and string length (array.length, not a LEN() function call), and its own random(a, b) function that is inclusive of both endpoints, unlike Python's exclusive-upper-bound randrange. It shares some structures with AQA's pseudocode, DO UNTIL behaves exactly like AQA's REPEAT UNTIL, running its body at least once before checking the exit condition, but the exact keyword casing and property-style syntax genuinely differ, so do not assume an AQA-taught answer transfers across unchanged.

Why does this page cover logic gates and SQL, when AQA's Paper 1 page does not?

Because OCR's J277 specification splits its two papers differently from AQA's 8525. For OCR, Boolean logic, logic gates and truth tables, along with SQL and databases, are genuinely tested on Paper 2 (Computational thinking, algorithms and programming), not Paper 1. Systems architecture, memory and storage, networks, network security, systems software and the ethical, legal, cultural and environmental impacts of technology are tested on Paper 1 (Computer systems) instead. If you are looking for those topics, they belong on our Paper 1 page, not this one.

How are the program-writing questions actually marked, if my code has a small mistake?

Every mark scheme we reviewed marks program-writing questions point by point against a genuine bullet-point checklist, awarding marks for real, distinct pieces of correct logic rather than an overall level judgement. The mark schemes explicitly state that minor syntax errors, case sensitivity, small spelling slips in variable names, should not be penalised as long as the intention and logic are clear, and that you do not have to declare which language you are using, since OCR marks for logical correctness in either the Exam Reference Language or a real high-level language you have studied, never a specific syntax.

What is the single biggest way marks are lost on this paper?

According to the real mark schemes for these three sittings, marks are very often lost on the logic-error and trace-table questions by fixing only one of the two errors, or by skipping the very first or the very last row of a trace, rather than any genuine misunderstanding of the algorithm itself. On the validation and boundary-condition questions, the single most repeated cause of lost marks across all three sittings was getting an inclusive boundary slightly wrong, using > instead of >=, or checking only one side of a range when the question genuinely needed both.

Practise the questions that are guaranteed to come up

Every question type on this page has practice questions waiting in the app, built the way OCR actually structures Paper 2.

Start revising free
Computer Science Paper 2: every question, answeredStart free