June 2025 80 marks · 1 hour 30 minutes · 6 questions
A real paper, in its real order. Each description and answer is ours, so you can see how each mark is earned. Not made or approved by OCR.
PrepWise guide: OCR GCSE Computer Science Paper 2Question 1
A program asks the user for a whole number and only accepts values from 1 to 100, including both ends. The program is being tested, and an algorithm has been written for it.
Show model answer for 01.2Hide model answer for 01.2
Gap 1: >= 1
Gap 2: num <= 100
Gap 3: else
num = input("Enter a number between 1 and 100")
if num >= 1 AND num <= 100 then
print("accepted")
else
print("not accepted")
endif
3 marks
How the marks are earned
One mark for each gap, up to 3.
BP1, gap 1: a check that num is at least 1; >= 1 or > 0 are both credited.
BP2, gap 2: a check that num is at most 100. The form num <= 100 or num < 101 is credited. The variable num must appear in this check.
The two checks may be written in either order, so the upper limit may come first.
BP3, gap 3: else. An elseif or elif is credited only if it carries a full correct comparison, such as num < 1 OR num > 100.
This is Section A, so wording such as less than or equal to is credited in place of the symbols.
Why it scores
The word num is already printed before the gap, so only the comparison is written here. The first AND condition rules out numbers below the bottom of the range. 1 itself must be allowed, so use >= and not >.
The second AND condition rules out numbers above the top of the range. 100 itself must be allowed, so use <= and not <. The condition has to name num again.
The else branch runs for every value that fails the check, so it prints the rejection message. Nothing needs to be compared here.
The finished algorithm. AND needs both checks to be true, so a number is accepted only when it is at least 1 and at most 100.
Show model answer for 02.2Hide model answer for 02.2
A FOR loop is count controlled. It repeats a set number of times.
A WHILE loop is condition controlled. It tests its condition before the code runs and repeats while that condition is true.
4 marks
How the marks are earned
Two marks for each loop, up to 4 in total. The marks are independent, and a description can score even if the loop is not named. Any two marks are credited for each loop.
FOR loop, up to 2 marks from three creditable points: (a) the loop is named; (b) it is count controlled; (c) it repeats a set number of times.
WHILE loop, up to 2 marks from three creditable points: (a) the loop is named; (b) it is condition controlled; (c) one mark for any one of these: it carries on as long as the condition holds, it stops once the condition is false, or the test is made before the body runs.
DO UNTIL or REPEAT UNTIL loop, credited instead, up to 2 marks from three points: (a) the loop is named; (b) it is condition controlled; (c) one mark for any one of these: it carries on until the condition holds, it carries on while the condition is false, or the test is made after the body has run.
Loops from other high-level languages are credited if suitable.
If both a WHILE and a DO UNTIL are given, condition controlled can describe both, but it is credited once only unless the two are told apart in some other way.
The description repeats infinitely earns nothing, because that is only true when the condition is never met.
No credit where the description fits a different loop, for example saying that a while loop carries on until its condition becomes true.
Why it scores
Two marks from three creditable points: the name, the type and the rule for repeating. Only two are needed.
Two marks from three creditable points: the name, the type and the rule for repeating. Only two are needed.
Show model answer for 02.4Hide model answer for 02.4
Tool 1: a code editor. It lets the programmer type in and change the program code, and fix errors.
Tool 2: a debugger. It finds errors in the program and shows the programmer where they are.
4 marks
How the marks are earned
For each tool, one mark for naming it and one mark for a matching description, up to 4. The description must add something beyond the tool name, and it must fit the tool named. If the tool name is wrong or missing, the description earns nothing. Other sensible names for a tool are accepted.
Text or code editor: it lets program code be written, entered or changed, or errors fixed.
Debugger, error reporting or diagnostics: it finds, identifies or checks for errors, shows where an error is or what it is, or suggests fixes.
Run-time environment or output window: it lets the program be run, or shows the output of the program.
Translator, compiler or interpreter: it converts the code to low-level or machine code, lets the program run, makes an executable file (compiler only) or stops at the first error (interpreter only). A translator and a compiler or interpreter are not both credited as two separate tools; compiler and interpreter as two separate tools are both credited with descriptions.
Stepping: it runs the program one line at a time.
Variable watch: it shows what the variables hold or how they change.
Breakpoints: they stop the program at a chosen place.
Pretty printing or keyword highlighting: it lets keywords or variables be coloured or identified.
Keyword completion, autocomplete, autocorrect or syntax suggestions: they suggest or correct code; saying it happens once the first part is typed is not needed.
GUI or GUI builder: it lets a user interface, such as buttons, be created.
Other sensible IDE features are credited, for example line numbers, auto indent or collapsing blocks, if the description says a little more than the name.
Features of a programming language, such as comments or casting, are not IDE tools and earn nothing.
Sensible references to AI are credited.
An editor, error diagnostics or debugger may be given a description that belongs to another feature in this list, for example the editor does pretty printing or the debugger does stepping.
Why it scores
Two marks: the tool, and a description that says what the tool is used for.
Two marks: the tool, and a matching description. The description fits the debugger and says more than its name.
PrepWise guide: OCR GCSE Computer Science Paper 2Question 3
The eight numbers in Figure 5 must be put in ascending order. A different task searches an array: it looks at the first item, halts if that item is the target, and otherwise goes on to the next item.
One mark for each stage, up to 4. Brackets are not needed, but it must be clear which numbers form each group of 2, 4 or 8.
BP1: the list is split into separate groups of one item. This may be done in several stages or all at once.
BP2: the single items join into ordered pairs: 2 with 7, 1 with 3, 6 with 9 and 4 with 5.
BP3: sorted groups of four are shown: 1 2 3 7 and 4 5 6 9.
BP4: one finished list in ascending order, 1 to 7 and then 9, reached by a reasonable attempt at merging the two fours into an eight. That list shown with no merging steps, or made by another algorithm, earns nothing.
Joining groups in the wrong order and sorting them afterwards does not earn BP3 or BP4.
With no splitting shown at all, the starting list counts as already divided, so BP2 to BP4 can still be earned. A faulty split loses BP1 only.
Using different numbers, or sorting into descending order, is penalised once and then followed through.
Why it scores
Merge sort first divides the list until every group holds one item. It then merges neighbouring groups, putting the numbers in order each time, until one sorted list remains.
Insertion sort: the array is split into a part already in order and a part still to doCorrect answer
Insertion sort: the first step is to pull out the middle item
Insertion sort: it joins separate arrays together
Bubble sort: after comparing two neighbours, it swaps them every time
Bubble sort: it swaps two neighbours only when they already sit the right way round
Bubble sort: it swaps two neighbours only when they sit the wrong way roundCorrect answer
Array: the number of items it holds is set when it is declaredCorrect answer
Array: it holds several values that the program cannot alter once stored
Array: it can have at most one dimension
Show model answer for 03.2Hide model answer for 03.2
Insertion sort: the array is split into a part already in order and a part still to do
Bubble sort: it swaps two neighbours only when they sit the wrong way round
Array: the number of items it holds is set when it is declared
3 marks
How the marks are earned
One mark for each group, up to 3. A group with more than one box ticked earns nothing.
Insertion sort: it uses an array with a sorted part and an unsorted part.
Bubble sort: a pair is swapped only when the two values sit the wrong way round.
Array: its length is fixed at the moment it is declared.
Why it scores
It takes each item from the unsorted part and inserts it in the right place in the sorted part. It does not start at the middle, and merging belongs to merge sort.
Swapping a pair that is already in order would undo the sort. Bubble sort only swaps a pair that is the wrong way round.
The size of an array is set when it is made. Its values can be changed while the program runs, and arrays can have more than one dimension.
Show model answer for 03.4Hide model answer for 03.4
It stops when it reaches the end of the list, having checked every value without finding the target.
1 mark
How the marks are earned
The end of the list has been reached, or the last value has been checked, or every value has been checked. Adding that the target was not found is not needed.
A bare answer that the value is not found or not in the list earns nothing. The idea of reaching the end or checking the whole list must be there.
PrepWise guide: OCR GCSE Computer Science Paper 2Question 4
A program works through the text file data.txt one number at a time and shows a number only when it is anything other than 0. Figure 6 is the program with five gaps.
Show model answer for 04.1Hide model answer for 04.1
myFile = open("data.txt")
while NOT myFile.endOfFile()
temp = myFile.readLine()
if int(temp) != 0
print(temp)
endif
endwhile
myFile.close()
Gap 1: open
Gap 2: myFile.readLine()
Gap 3: temp
Gap 4: print
Gap 5: myFile.close()
5 marks
How the marks are earned
One mark for each gap, up to 5. Only one choice per gap: a gap with several options chosen earns nothing.
BP1, gap 1: open.
BP2, gap 2: myFile.readLine(). The form readLine is credited.
BP3, gap 3: temp. The choice myFile.readLine() is credited here only if it was not used in gap 2.
BP4, gap 4: print.
BP5, gap 5: myFile.close(). The form close is credited.
Spelling slips, capital letters and minor differences are ignored as long as it is clear which option was chosen.
Why it scores
open opens the file for reading. Each pass of the loop reads one line into temp, tests it as a number, and prints it only if it is not 0. close finishes with the file once the loop ends.
The five answers in gap order. Words such as data, txt, x and input() are the unused ones.
PrepWise guide: OCR GCSE Computer Science Paper 2Question 5
An online payment checker takes three inputs. A is true if the password typed is right, B is true if the PIN typed is right, and C is true if the card has been blocked. Output P is true when the user passes either check and the card is not blocked. In 05.4 no check that the digits are numeric is needed.
BP1: an OR gate that has two inputs. Any OR gate with two inputs is credited.
BP2: a NOT gate on input C.
BP3: the OR gate output and the NOT gate output joined by an AND gate. This mark can follow through where sensible, for example if a NOT gate is missing or wrong, or the wrong gate was used instead of OR.
Gate shapes must be correct: a NOT gate has a small circle, and AND and OR gates have no circle.
A maximum of 2 marks if there are extra gates or the circuit does not work logically.
Why it scores
The drawn circuit written as one Boolean expression: A and B go into an OR gate, because either the password or the PIN is enough. C goes through a NOT gate, because the card must not be blocked. An AND gate needs both results to be true.
One mark for each correct link, up to 3. A technique with more than one link earns nothing for it.
Abstraction is linked to the third example box.
Decomposition is linked to the first example box.
Algorithmic thinking is linked to the bottom example box.
Why it scores
Abstraction keeps only the details that matter, here identity, PIN and password, and ignores all other data.
Decomposition splits a big problem into smaller parts, here a security module and a payments module.
Algorithmic thinking plans a step by step process, here the steps a user follows to pay safely. The second example, more RAM, is not a thinking technique at all.
Show model answer for 05.4Hide model answer for 05.4
pin = input("Enter PIN")
if pin.length == 4 AND pin != "1234" AND pin != "4321" then
print("VALID PIN")
else
print("INVALID PIN")
endif
6 marks
How the marks are earned
One mark for each point, up to 6. This is Section A, so pseudocode, structured English or a flowchart can score, but the answer must not just repeat the question.
BP1: the PIN is taken as input and stored or used.
BP2: an attempt at selection, or at a condition controlled loop.
BP3: a correct check that the PIN has 4 characters.
BP4: a correct check that the PIN is not 1234 and not 4321. BP3 and BP4 may be one combined check, if it works, or two separate checks, and either may test for the good case or the bad case. Each comparison, with 1234 and with 4321, must name the variable.
BP5: every invalid PIN produces INVALID PIN (once or several times), provided all three checks were sensibly attempted, even if VALID PIN is printed as well. A sensible but wrong attempt at BP3 and BP4 still counts.
BP6: provided all three checks were sensibly attempted, VALID PIN is printed only for a fully valid PIN, with no contradictory output such as INVALID PIN as well. A sensible but wrong attempt at BP3 and BP4 still counts.
& for AND, and | or || for OR, are accepted.
Taking in or comparing the PIN as an integer gets benefit of the doubt. No quotation marks are needed round 1234 or 4321. Equivalent output messages are credited.
A flowchart is read by its text and not its shapes.
Why it scores
The PIN is stored, then one if statement tests all three rules together. AND means every rule must pass, so VALID PIN is printed only for a good PIN. The else branch prints INVALID PIN for everything else, so the two messages never appear together.
PrepWise guide: OCR GCSE Computer Science Paper 2Question 6
A yearly music festival called OCR Rockfest sells entry tickets and runs a computer system holding details of its visitors and its bands. Figure 10 shows part of the table TblMusic, which lists the acts. A ticket costs 60 pounds, so 4 tickets come to 240 pounds. There are 500 tickets at the start, and the variable tickets holds how many are left, starting from the line tickets = 500. Booking prints Tickets booked and a refusal prints Not enough tickets. Answers to 06.6, 06.7 and 06.11 are code: write them in the board's reference language or in a language you have studied.
Show model answer for 06.2Hide model answer for 06.2
if passA == passB then
print("passwords match")
else
print("passwords do not match")
endif
3 marks
How the marks are earned
One mark for each point, up to 3. A flowchart is accepted: it needs a decision diamond for BP1, labelled True and False branches for BP2 and BP3, and output boxes for BP2 and BP3.
BP1: a check that passA and passB are equal.
BP2: the correct output when they are equal. Other message wording is credited.
BP3: the correct output when they are not equal. Other message wording is credited.
The checks may be separate if statements. An elseif or elif on its own earns BP1 only if it holds a full comparison, such as passA != passB, and then BP2 and BP3 follow through.
BP2 and BP3 need a sensible attempt at the comparison in BP1.
The names passA and passB must be right. Spaces are penalised only if clearly visible. Capital letters are ignored. Extra code, such as further inputs, is ignored if it does not change the result.
Why it scores
A double equals compares the two values. The if branch runs when they are the same and the else branch runs for any difference, so exactly one message is printed.
Show model answer for 06.3Hide model answer for 06.3
SELECT ActID, Stage
FROM TblMusic
WHERE Day = "Saturday"
4 marks
How the marks are earned
One mark for each correct refinement, up to 4. A written description of the change is credited.
BP1: the SELECT line is SELECT ActID, Stage, with a comma between the two fields.
BP2: the table name is corrected to TblMusic.
BP3: the keyword WHERE is used.
BP4: the condition is Day = "Saturday", with the value in quotation marks. The form == is credited.
Quotation marks round field and table names are allowed. Spelling in field and table names must be exact. Spaces are penalised only if clearly visible. Capital letters are ignored.
A maximum of 3 marks if the final SQL is invalid, in the wrong order or has extra code.
If the same error is made twice, it is penalised once and then followed through.
Why it scores
Four fixes. A comma replaces AND between the fields. The table is named TblMusic and not TblActs. WHERE is the keyword that filters records, not IF. The value Saturday is text, so it goes in quotation marks.
Show model answer for 06.4Hide model answer for 06.4
1, Platinum, Saturday, 0.5
1 mark
How the marks are earned
Any one complete record taken from the table, or any sensible new record with four separate items of data. Field names written with the data are allowed.
The order of the data, capital letters, spelling and data types are ignored.
Show model answer for 06.6Hide model answer for 06.6
function calculatePrice(quantity)
total = quantity * 60
return total
endfunction
4 marks
How the marks are earned
Up to 4 marks, one per point. This is Section B, so it must be high level code: the board's reference language or a language the student has studied. Pseudocode or plain English earns nothing.
BP1: a function definition named calculatePrice.
BP2: a parameter in the definition, which is not overwritten inside the function. Further parameters are fine.
BP3: the total is worked out by multiplying the parameter by 60. The letter x for times is not accepted. If there is no parameter, multiplying by a sensible value such as an input is allowed. A parameter that is overwritten follows through.
BP4: the total is always returned. The return must be a return, and print or output earns nothing. The value may carry a pound sign and other text. Returning by assigning the value to the function name, as some languages do, is credited. This mark follows through if a sensible attempt was made at the calculation.
Clearly visible spaces inside a function, variable or parameter name are not accepted.
If a function definition is written, every line belongs inside it. Extra code is ignored.
Why it scores
The parameter quantity holds the number of tickets, and total = quantity * 60 gives the cost. return sends that value back to the caller. Printing it instead would not return it.
Show model answer for 06.8Hide model answer for 06.8
Line count x Output
01 0
02 0
03 10
02 1
03 24
02 2
03 30
05 30
4 marks
How the marks are earned
One mark for each point, up to 4. Line numbers are ignored and not required. The order of the values is marked, and a value may be repeated down a column, so changes are what count.
BP1: count starts at 0.
BP2: count then goes to 10, then 24, then 30, with no other changes.
BP3: x goes 0, then 1, then 2 (3 may also be shown), with no other changes.
BP4: 30 is output, and nothing else is output. If a wrong total was worked out and then output, this mark follows through, and the last value of count is credited as the output.
A dash or the word nothing in the output column on other rows is given benefit of the doubt. print(30) or an equivalent written in the output column earns nothing.
Why it scores
Each row records only the value that changes on that line. count starts at 0 and then adds actNumbers[x] each pass: 0 + 10 is 10, 10 + 14 is 24, 24 + 6 is 30. x counts 0, 1, 2 as the loop runs, and 30 is printed once the loop ends.
Show model answer for 06.9Hide model answer for 06.9
Line 02
for x = 0 to 4
2 marks
How the marks are earned
One mark for the line number: line 02.
One mark for updated code that loops through all five cells, such as for x = 0 to 4. The counter must be x.
Rewrites in other high level languages are accepted. The form 0 to 5 or range(5) is given benefit of the doubt.
Any other change that works is credited, such as using the length of actNumbers.
Why it scores
Line 02 is the for line, the one that sets how many times the loop runs, so it is the only line that must change.
The array now has five cells, at index 0 to 4, so the loop must run until x is 4. Only the end value of the loop changes. Line 03 already adds the cell at index x.
Show model answer for 06.10Hide model answer for 06.10
print("The total act count is " + str(count))
1 mark
How the marks are earned
A print statement holding the sentence, a joining symbol and then count. A different joiner such as & or a dot is credited, and so is a comma.
A separator between the text and the number is needed. Spacing, capital letters and casting are ignored.
A command equivalent to print, such as echo or output, is credited. Several print statements, or several lines of code that give the result, are credited.
Putting count inside the string so that its value prints is credited too, for example {count}, an f string, or a dollar sign before the variable inside the quotation marks.
Why it scores
The text and the number are joined with +. str() turns the number into text so that it can be joined. The mark scheme ignores casting here, so leaving it out would still earn the mark.
Complete the algorithm: input tickets wanted, print Tickets booked and reduce tickets if enough remain, else print Not enough tickets; repeat until none left.
Show model answer for 06.11Hide model answer for 06.11
tickets = 500
while tickets > 0
num = int(input("How many tickets would you like?"))
if tickets >= num then
print("Tickets booked")
tickets = tickets - num
else
print("Not enough tickets")
endif
endwhile
6 marks
How the marks are earned
Up to 6 marks, one per point. This is Section B, so it must be high level code: the board's reference language or a language the student has studied. Pseudocode or plain English earns nothing.
BP1: the number of tickets wanted is input and stored or used.
BP2: a check for whether enough tickets are left. It must allow a booking when exactly the number wanted remain, for example 5 wanted and 5 left, so the comparison must not rule that out.
BP3: a sensible message for each case, booked and not enough tickets, the right way round. This depends on BP2.
BP4: the tickets variable is updated correctly when a booking is made. This depends on BP2.
If BP2 is wrong or missing but there is a reasonable attempt, such as checking whether tickets is above 0, BP3 and BP4 can follow through.
BP5: any attempt at a loop.
BP6: everything attempted above repeats while tickets > 0, or while tickets != 0, or until tickets <= 0, or until tickets = 0. The input, if there is one, must be inside the loop so it repeats, and tickets must not be set back to 500 each time round.
Extra code is ignored.
Why it scores
The loop keeps going while tickets is above 0, and the input is inside the loop so it is asked every time. The test tickets >= num allows the very last tickets to be booked. A booking subtracts num from tickets, and a request that is too large leaves tickets alone and prints the other message. tickets = 500 sits before the loop so it is never reset.
Cookies. Essential ones keep you signed in. With your OK we'd also use a few to see which pages help people find us, never to follow you elsewhere. Cookie policy