Paper 2

PrepWiseGuide to a real paper

OCR GCSE Computer Science

Paper 2

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.

Figure 1
A table of four test values with empty tick columns for normal, boundary and invalid data.Open full size to read the labels (Figure 1, opens in a new tab)
Figure 2
An algorithm of six lines with three gaps marked by numbered black circles.Open full size to read the labels (Figure 2, opens in a new tab)
01.1[4 marks]

Tick one or more boxes against each value in Figure 1, to name its type or types of test data.

See how you would score on Testing
Normal
Boundary
Invalid / erroneous
Show model answer for 01.1Hide model answer for 01.1

27: Normal

"Hello": Invalid / erroneous

105: Invalid / erroneous

100: Boundary (and also Normal)

4 marks

How the marks are earned

  1. One mark for each row, up to 4.
  2. 27: normal.
  3. "Hello": invalid or erroneous.
  4. 105: invalid or erroneous.
  5. 100: boundary, or boundary and normal together. Boundary alone is credited, and so is boundary with normal.

Why it scores

27 is a sensible value inside the range 1 to 100 and is not on an edge.

Text is the wrong type of data. The program wants a whole number.

105 is a number but it is above the largest value allowed, 100.

100 sits exactly on the edge of the allowed range, so it is boundary data. It is also accepted by the program, so ticking normal as well is credited.

Revise Testing
01.2[3 marks]

Complete the algorithm in Figure 2 by filling the three numbered gaps so that 1 to 100 is accepted and other numbers are rejected.

See how you would score on Selection (IF Statements)
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

  1. One mark for each gap, up to 3.
  2. BP1, gap 1: a check that num is at least 1; >= 1 or > 0 are both credited.
  3. 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.
  4. The two checks may be written in either order, so the upper limit may come first.
  5. 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.
  6. 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.

Revise Selection (IF Statements)
01.3[1 mark]

Give an identifier for one variable that the completed algorithm uses.

See how you would score on Variables & Constants
Show model answer for 01.3Hide model answer for 01.3
num
1 mark

How the marks are earned

  1. num.
  2. Extra code around the name earns nothing. Capital letters and small spelling slips are ignored.
Revise Variables & Constants
01.4[1 mark]

Give one Boolean operator that the completed algorithm uses.

See how you would score on Boolean Expressions
Show model answer for 01.4Hide model answer for 01.4
AND
1 mark

How the marks are earned

  1. AND.
  2. Extra code around the operator earns nothing. Capital letters and small spelling slips are ignored.
Revise Boolean Expressions
OCR owns the copyright in its exam questions, so we cannot copy their wording. These descriptions and answers are ours. Not made or approved by OCR.[9 marks]
PrepWise guide: OCR GCSE Computer Science Paper 2Question 2

Figure 3 shows a loop drawn as a flowchart. A programmer is going to write it as a high-level language program, using an IDE.

Figure 3
A flowchart with start, an input box, an output box, a process box, a decision with a loop back, and an end.Open full size to read the labels (Figure 3, opens in a new tab)
Figure 4
A table with two inputs and an empty column for the number of outputs.Open full size to read the labels (Figure 4, opens in a new tab)
02.1[2 marks]

Complete Figure 4: identify how many times OK is output for each input value when Figure 3 runs.

See how you would score on Trace Tables
Show model answer for 02.1Hide model answer for 02.1
Input 3
x = 3
OK (1)
x = 1, 1 < 0 is false
OK (2)
x = -1, -1 < 0 is true
stop
2 times
Input 10
x = 10
OK (1), x = 8
OK (2), x = 6
OK (3), x = 4
OK (4), x = 2
OK (5), x = 0, 0 < 0 is false
OK (6), x = -2, -2 < 0 is true
stop
6 times
2 marks

How the marks are earned

  1. One mark for each input value, up to 2.
  2. Input 3: OK is output 2 times.
  3. Input 10: OK is output 6 times.

Why it scores

Each pass outputs OK, then subtracts 2, then tests x. The loop only ends once x has gone below 0.

0 is not less than 0, so the loop goes round once more. That is why the count is 6 and not 5.

Revise Trace Tables
02.2[4 marks]

Identify and describe two different kinds of iteration that a high-level language offers.

See how you would score on Iteration (Loops)
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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Loops from other high-level languages are credited if suitable.
  6. 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.
  7. The description repeats infinitely earns nothing, because that is only true when the condition is never met.
  8. 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.

Revise Iteration (Loops)
02.3[2 marks]

Give the names of two programming constructs, other than iteration, that high-level languages use.

See how you would score on Selection (IF Statements)
Show model answer for 02.3Hide model answer for 02.3

Sequence

Selection

2 marks

How the marks are earned

  1. One mark for each construct, up to 2.
  2. Sequence. The form sequencing is credited.
  3. Selection. Branching is credited in its place.
  4. A bare example such as IF with no construct name earns nothing.

Why it scores

Sequence means instructions run one after another in the order they are written.

Selection means the program chooses which instructions to run, for example with an if statement.

Revise Selection (IF Statements)
02.4[4 marks]

Identify and describe two IDE tools the programmer could use to create the program from Figure 3.

See how you would score on IDE Features
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

  1. 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.
  2. Text or code editor: it lets program code be written, entered or changed, or errors fixed.
  3. Debugger, error reporting or diagnostics: it finds, identifies or checks for errors, shows where an error is or what it is, or suggests fixes.
  4. Run-time environment or output window: it lets the program be run, or shows the output of the program.
  5. 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.
  6. Stepping: it runs the program one line at a time.
  7. Variable watch: it shows what the variables hold or how they change.
  8. Breakpoints: they stop the program at a chosen place.
  9. Pretty printing or keyword highlighting: it lets keywords or variables be coloured or identified.
  10. Keyword completion, autocomplete, autocorrect or syntax suggestions: they suggest or correct code; saying it happens once the first part is typed is not needed.
  11. GUI or GUI builder: it lets a user interface, such as buttons, be created.
  12. 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.
  13. Features of a programming language, such as comments or casting, are not IDE tools and earn nothing.
  14. Sensible references to AI are credited.
  15. 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.

Revise IDE Features
OCR owns the copyright in its exam questions, so we cannot copy their wording. These descriptions and answers are ours. Not made or approved by OCR.[12 marks]
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.

Figure 5
A list of eight whole numbers separated by commas.Open full size to read the labels (Figure 5, opens in a new tab)
03.1[4 marks]

Show each stage of a merge sort that sorts the numbers in Figure 5 into ascending order.

See how you would score on Merge Sort
Show model answer for 03.1Hide model answer for 03.1
Divide
[2 7 3 1 9 6 5 4]
[2 7 3 1] [9 6 5 4]
[2 7] [3 1] [9 6] [5 4]
[2] [7] [3] [1] [9] [6] [5] [4]

Merge
[2 7] [1 3] [6 9] [4 5]
[1 2 3 7] [4 5 6 9]
[1 2 3 4 5 6 7 9]
4 marks

How the marks are earned

  1. 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.
  2. BP1: the list is split into separate groups of one item. This may be done in several stages or all at once.
  3. BP2: the single items join into ordered pairs: 2 with 7, 1 with 3, 6 with 9 and 4 with 5.
  4. BP3: sorted groups of four are shown: 1 2 3 7 and 4 5 6 9.
  5. 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.
  6. Joining groups in the wrong order and sorting them afterwards does not earn BP3 or BP4.
  7. 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.
  8. 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.

Revise Merge Sort
03.2[3 marks]

Tick one box in each of the three tables, on insertion sort, bubble sort and arrays, to give correct statements.

See how you would score on Bubble Sort
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

  1. One mark for each group, up to 3. A group with more than one box ticked earns nothing.
  2. Insertion sort: it uses an array with a sorted part and an unsorted part.
  3. Bubble sort: a pair is swapped only when the two values sit the wrong way round.
  4. 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.

Revise Bubble Sort
03.3[1 mark]

Give the name of the algorithm for searching that these steps describe.

See how you would score on Linear Search
Show model answer for 03.3Hide model answer for 03.3

Linear search

1 mark

How the marks are earned

  1. Linear search. The word linear on its own is credited. Linear sort is not.
Revise Linear Search
03.4[1 mark]

Identify one other condition that stops this search.

See how you would score on Linear Search
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

  1. 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.
  2. 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.
Revise Linear Search
OCR owns the copyright in its exam questions, so we cannot copy their wording. These descriptions and answers are ours. Not made or approved by OCR.[9 marks]
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.

Figure 6
An algorithm of eight lines with five gaps marked by numbered black circles.Open full size to read the labels (Figure 6, opens in a new tab)
04.1[5 marks]

Complete Figure 6 by choosing OCR Exam Reference Language statements from the box for gaps 1 to 5. Not every word is used.

See how you would score on File Handling
data
for
if
myFile.close()
myFile.readLine()
input()
myFile.writeLine()
open
print
temp
txt
x
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

  1. One mark for each gap, up to 5. Only one choice per gap: a gap with several options chosen earns nothing.
  2. BP1, gap 1: open.
  3. BP2, gap 2: myFile.readLine(). The form readLine is credited.
  4. BP3, gap 3: temp. The choice myFile.readLine() is credited here only if it was not used in gap 2.
  5. BP4, gap 4: print.
  6. BP5, gap 5: myFile.close(). The form close is credited.
  7. 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.

Revise File Handling
04.2[1 mark]

Identify how this algorithm uses casting.

See how you would score on Data Types
Show model answer for 04.2Hide model answer for 04.2

int(temp) converts the text read from the file into an integer, so it can be compared with 0.

1 mark

How the marks are earned

  1. It converts the data to an integer (to int).
  2. A vague answer such as changes it to a different data type earns nothing.
Revise Data Types
OCR owns the copyright in its exam questions, so we cannot copy their wording. These descriptions and answers are ours. Not made or approved by OCR.[6 marks]
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.

Figure 7
An empty frame for a logic circuit: three inputs A, B and C on the left, an empty area in the middle and the output P on the right.Open full size to read the labels (Figure 7, opens in a new tab)
Figure 8
A truth table with columns A, B and P and four empty rows.Open full size to read the labels (Figure 8, opens in a new tab)
Figure 9
Three technique boxes on the left and four example boxes on the right.Open full size to read the labels (Figure 9, opens in a new tab)
05.1[3 marks]

Draw the logic circuit in Figure 7 that gives output P from inputs A, B and C.

See how you would score on Logic Gates
Show model answer for 05.1Hide model answer for 05.1
P = (A OR B) AND NOT C
Answer for 05.1
A completed logic circuit with three gates and wires from inputs A, B and C to output P.Open full size to read the labels (Answer for 05.1, opens in a new tab)
3 marks

How the marks are earned

  1. One mark for each point, up to 3.
  2. BP1: an OR gate that has two inputs. Any OR gate with two inputs is credited.
  3. BP2: a NOT gate on input C.
  4. 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.
  5. Gate shapes must be correct: a NOT gate has a small circle, and AND and OR gates have no circle.
  6. 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.

Revise Logic Gates
05.2[2 marks]

Complete the truth table in Figure 8 for the output P of an AND gate with inputs A and B.

See how you would score on Truth Tables
Show model answer for 05.2Hide model answer for 05.2
A  B  P
0  0  0
0  1  0
1  0  0
1  1  1
2 marks

How the marks are earned

  1. One mark for all four combinations of A and B: 00, 01, 10 and 11. They need not be in order.
  2. One mark for the P column: 1 for the one row where both inputs are 1, and 0 for the remaining three rows.
  3. T and F, yes and no, or ticks and crosses are credited in place of 1 and 0.

Why it scores

Two inputs give four combinations. AND is only true when both inputs are true, so only the last row has P = 1.

Revise Truth Tables
05.3[3 marks]

Draw one line from each technique in Figure 9 to its correct example.

See how you would score on Computational Thinking
Abstraction
Decomposition
Algorithmic thinking
Show model answer for 05.3Hide model answer for 05.3

Abstraction to the third example

Decomposition to the first example

Algorithmic thinking to the fourth example

Answer for 05.3
The matching figure again, with a line drawn from each technique box to one example box.Open full size to read the labels (Answer for 05.3, opens in a new tab)
3 marks

How the marks are earned

  1. One mark for each correct link, up to 3. A technique with more than one link earns nothing for it.
  2. Abstraction is linked to the third example box.
  3. Decomposition is linked to the first example box.
  4. 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.

Revise Computational Thinking
05.4[6 marks]

Create an algorithm that reads the PIN typed in as a string, printing VALID PIN for four characters not 1234 or 4321, else INVALID PIN.

See how you would score on Input Validation
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

  1. 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.
  2. BP1: the PIN is taken as input and stored or used.
  3. BP2: an attempt at selection, or at a condition controlled loop.
  4. BP3: a correct check that the PIN has 4 characters.
  5. 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.
  6. 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.
  7. 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.
  8. & for AND, and | or || for OR, are accepted.
  9. 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.
  10. 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.

Revise Input Validation
OCR owns the copyright in its exam questions, so we cannot copy their wording. These descriptions and answers are ours. Not made or approved by OCR.[14 marks]
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.

Figure 10
A database table named TblMusic with four fields and four records.Open full size to read the labels (Figure 10, opens in a new tab)
Figure 11
Three lines of a database query.Open full size to read the labels (Figure 11, opens in a new tab)
Figure 12
A table with three columns, two rows, and an empty data type column.Open full size to read the labels (Figure 12, opens in a new tab)
Figure 13
Five numbered lines of an algorithm with a loop.Open full size to read the labels (Figure 13, opens in a new tab)
Figure 14
An array named actNumbers with three cells at index 0, 1 and 2.Open full size to read the labels (Figure 14, opens in a new tab)
Figure 15
A trace table with columns for line number, count, x and output, and fourteen empty rows.Open full size to read the labels (Figure 15, opens in a new tab)
Figure 16
An array named actNumbers with five cells at index 0 to 4.Open full size to read the labels (Figure 16, opens in a new tab)
06.1[1 mark]

Tick one box for the correct statements, in OCR Exam Reference Language, that store a password entered twice, in passA and passB.

See how you would score on Variables & Constants
passA and passB = input("type it two times")
input("first password") = passA, then input("second password") = passB
passA = input("first password"), then passB = input("second password")Correct answer
"passA" = input("first password"), then "passB" = input("second password")
Show model answer for 06.1Hide model answer for 06.1
passA = input("first password")
passB = input("second password")
1 mark

How the marks are earned

  1. The third option: passA = input(...) on one line, then passB = input(...) on the next.
Revise Variables & Constants
06.2[3 marks]

Design an algorithm that compares passA and passB, printing passwords match if equal and passwords do not match if not.

See how you would score on Selection (IF Statements)
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

  1. 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.
  2. BP1: a check that passA and passB are equal.
  3. BP2: the correct output when they are equal. Other message wording is credited.
  4. BP3: the correct output when they are not equal. Other message wording is credited.
  5. 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.
  6. BP2 and BP3 need a sensible attempt at the comparison in BP1.
  7. 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.

Revise Selection (IF Statements)
06.3[4 marks]

Refine the SQL in Figure 11, correcting its errors, to list ActID and Stage for the Saturday acts.

See how you would score on SQL
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

  1. One mark for each correct refinement, up to 4. A written description of the change is credited.
  2. BP1: the SELECT line is SELECT ActID, Stage, with a comma between the two fields.
  3. BP2: the table name is corrected to TblMusic.
  4. BP3: the keyword WHERE is used.
  5. BP4: the condition is Day = "Saturday", with the value in quotation marks. The form == is credited.
  6. 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.
  7. A maximum of 3 marks if the final SQL is invalid, in the wrong order or has extra code.
  8. 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.

Revise SQL
06.4[1 mark]

Identify one record that could be stored in TblMusic.

See how you would score on SQL
Show model answer for 06.4Hide model answer for 06.4
1, Platinum, Saturday, 0.5
1 mark

How the marks are earned

  1. 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.
  2. The order of the data, capital letters, spelling and data types are ignored.
  3. A definition of what a record is earns nothing.
Revise SQL
06.5[2 marks]

Give the best data type for Stage and for SetLength in Figure 12.

See how you would score on Data Types
Show model answer for 06.5Hide model answer for 06.5

Stage: string

SetLength: real, also called float

2 marks

How the marks are earned

  1. One mark for each field, up to 2.
  2. Stage: string. Text, varchar or char are credited.
  3. SetLength: real or float. Decimal, single, double or numeric are credited.
  4. Other equivalent data types used by databases are accepted.

Why it scores

A stage name is made of letters, so it is text.

Lengths in hours include values like 0.5 and 1.5, so the type must hold decimals.

Revise Data Types
06.6[4 marks]

Write calculatePrice, a function that receives the ticket count as a parameter and returns what the visitor pays, at 60 pounds each.

See how you would score on Variable Scope
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

  1. 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.
  2. BP1: a function definition named calculatePrice.
  3. BP2: a parameter in the definition, which is not overwritten inside the function. Further parameters are fine.
  4. 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.
  5. 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.
  6. Clearly visible spaces inside a function, variable or parameter name are not accepted.
  7. 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.

Revise Variable Scope
06.7[2 marks]

Write an algorithm that makes use of calculatePrice() for 3 tickets and keeps the result in totalPrice.

See how you would score on Variable Scope
Show model answer for 06.7Hide model answer for 06.7
totalPrice = calculatePrice(3)
2 marks

How the marks are earned

  1. One mark for each point, up to 2. This is Section B, so it must be high level code.
  2. BP1: calculatePrice is called with 3 passed in. More than one value may be passed, if 3 is one of them.
  3. BP2: the returned value is assigned to totalPrice (any assignment sign); a double equals earns nothing.
  4. A sensible attempt at the call, such as a missing or wrong value, lets BP2 follow through.
  5. A new definition of the function earns nothing, because the existing function must be called.
  6. Spaces in the names are penalised only if clearly present. Capital letters and extra code are ignored.

Why it scores

The call passes 3 as the parameter, the function returns the cost, and the single equals stores that value in totalPrice.

Revise Variable Scope
06.8[4 marks]

Complete the trace table, Figure 15, for Figure 13 run on the array in Figure 14. You may not need every row.

See how you would score on Trace Tables
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

  1. 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.
  2. BP1: count starts at 0.
  3. BP2: count then goes to 10, then 24, then 30, with no other changes.
  4. BP3: x goes 0, then 1, then 2 (3 may also be shown), with no other changes.
  5. 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.
  6. 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.

Revise Trace Tables
06.9[2 marks]

Identify the line number in Figure 13 to change for the five-cell array in Figure 16, and write the updated line.

See how you would score on Iteration (Loops)
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

  1. One mark for the line number: line 02.
  2. One mark for updated code that loops through all five cells, such as for x = 0 to 4. The counter must be x.
  3. Rewrites in other high level languages are accepted. The form 0 to 5 or range(5) is given benefit of the doubt.
  4. 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.

Revise Iteration (Loops)
06.10[1 mark]

Refine line 05 of Figure 13 so it prints the words The total act count is, then the value held in count.

See how you would score on String Handling
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

  1. 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.
  2. A separator between the text and the number is needed. Spacing, capital letters and casting are ignored.
  3. 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.
  4. 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.

Revise String Handling
06.11[6 marks]

Complete the algorithm: input tickets wanted, print Tickets booked and reduce tickets if enough remain, else print Not enough tickets; repeat until none left.

See how you would score on Iteration (Loops)
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

  1. 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.
  2. BP1: the number of tickets wanted is input and stored or used.
  3. 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.
  4. BP3: a sensible message for each case, booked and not enough tickets, the right way round. This depends on BP2.
  5. BP4: the tickets variable is updated correctly when a booking is made. This depends on BP2.
  6. 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.
  7. BP5: any attempt at a loop.
  8. 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.
  9. 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.

Revise Iteration (Loops)
OCR owns the copyright in its exam questions, so we cannot copy their wording. These descriptions and answers are ours. Not made or approved by OCR.[30 marks]
END OF QUESTIONS80 marks total
See how you would score on Iteration (Loops)

Our own questions on this topic, marked straight away, so you see what to revise. Free now.