OCR GCSE Computer Science Computational thinking, algorithms and programming (02), June 2025: Question 6
30 marks · Hard difficulty · Programming
Design, trace, and refine algorithms and code for a festival management system, including SQL queries, subprograms, trace tables, and loops.
Practise this questionQuestion
Question text
Section B
We advise you to spend approximately 40 minutes on Section B.
Some questions require you to respond using either the OCR Exam Reference Language or a
high-level programming language you have studied. These are clearly shown.
6 OCR Rockfest is a yearly music festival. Visitors buy tickets to attend and watch the music acts.
A computer system is created to sell tickets and store information about visitors and the music
acts.
(a) Visitors are asked to choose a password. The password is entered twice and stored in the
variables passA and passB
(i) Tick (✓) one box to identify the correct OCR Exam Reference Language statements for the
design of this task.
Tick (✓)
OCR Exam Reference Language to enter two passwords
one
passA and passB = input("enter password twice")
input("enter your password") = passA
input("enter your password again") = passB
passA = input("enter your password")
passB = input("enter your password again")
"passA" = input("enter your password")
"passB" = input("enter your password again")
[1]
(ii) Design an algorithm that:
• checks if the passwords stored in passA and passB are the same
• outputs "passwords match" if they are the same
• outputs "passwords do not match" if they are not the same.
… [3]
(b) The database table TblMusic stores data about the music acts.
Some of the data in TblMusic is shown:
ActID Stage Day SetLength
1 Platinum Saturday 0.5
2 Hills Saturday 1.5
3 Triangle Sunday 1.0
4 Platinum Sunday 0.5
An SQL statement has been written to show ActID and Stage for all acts playing on Saturday.
The SQL statement is incorrect.
SELECT ActID AND Stage
FROM TblActs
IF Day = Saturday
(i) Refine the SQL statement to correct the errors.
… [4]
(ii) Identify one example of a record from TblMusic
… [1]
(iii) Give the most appropriate data type for each field shown.
Field name Data stored Data type
Stage The name of the stage
SetLength The length of each set in
hours
13 [2]
(c) Tickets to the festival are £60 each. Visitors can buy multiple tickets. For example, a visitor
buying 4 tickets would pay £240.
(i) Write a function, calculatePrice() that:
• takes the number of tickets to be purchased as a parameter
• calculates and returns the total price to pay.
You must use either:
• OCR Exam Reference Language, or
• a high-level programming language that you have studied.
… [4]
(ii) Write an algorithm that:
• uses the function calculatePrice() to find the price for a visitor buying 3 tickets
• stores the result in the variable totalPrice
You must use either:
• OCR Exam Reference Language, or
• a high-level programming language that you have studied.
… 14 [2]
(d) The number of different music acts on each of the three stages is stored in the array
actNumbers.
Each index of the array represents one stage.
Index 0 1 2
Data 10 14 6
actNumbers
This algorithm adds up the total number of acts on all three stages.
01 count = 0
02 for x = 0 to 2
03 count = count + actNumbers[x]
04 next x
05 print(count)
(i) Complete the trace table for the algorithm. You may not need to use all rows in the table.
Line number count x Output
[4]
(ii) The array actNumbers is changed to include data for two more stages. The new array is shown:
Index 0 1 2 3 4
Data 10 14 6 9 11
actNumbers
The algorithm from part (i) needs refining to work for the new array. The algorithm is repeated
here:
01 count = 0
02 for x = 0 to 2
03 count = count + actNumbers[x]
04 next x
05 print(count)
Identify the line number that will need to be changed for the new array and write the updated line
of code.
Line number …
Updated code …
[2]
(iii) Refine line 05 in the algorithm to output "The total act count is " and then the content
of the variable count
For example:
The total act count is 50
New line 05 …
… [1]
(e) There are 500 tickets available for the music festival. The number of tickets currently available is
stored in the variable tickets
Complete the algorithm to:
• prompt the user to enter how many tickets they would like and take this value as input
• output "Tickets booked" and reduce the value stored in tickets if there are enough
tickets available
• output "Not enough tickets" if there are not enough tickets available
• repeat the steps until there are no tickets left.
You must use either:
• OCR Exam Reference Language, or
• a high-level programming language that you have studied
tickets = 500
… [6]
Mark scheme
Show the mark scheme
Question Answer Mark Guidance
6 (a) (i) • 3rd box ticked 1
6 (a) (ii) • Checks if passA and passB are equal… 3 Example code
• …Correct output if True if passA == passB:
print("passwords match")
• …Correct output if False
else
print("passwords do not match")
Design so answer can be flowchart, etc. If
end if
flowchart, decision (diamond) box needed for BP1,
True / False labels essential for BP2 and 3. Output
Allow alternative messages.
(parallelogram) box needed for BP2 and 3.
Ignore superfluous code (including inputs or
overwriting variables) as long as it does not affect
outcome.
Could be done as separate if statements. Do not
allow elseif/elif etc by itself for BP1 unless
complete logical comparison (e.g. elif passA
!= passB). FT to BP2 and 3.
BP2 and 3 require a sensible attempt at
comparing variables in BP1 to be given.
passA and passB must be correct with no
spaces. Ignore case. Penalise spaces only if clear
and obvious.
6 (b) (i) One mark per refinement 4 Allow descriptions of change. Allow quote marks
around field and table names. Allow == for BP4.
• SELECT ActID , Stage
• FROM TblMusic Spellings / spaces in field/table names must be
• WHERE accurate. Penalise spaces only if clear and
• Day = "Saturday" obvious. Ignore case.
Max 3 if final SQL is invalid / in wrong order / has
extra superfluous code.
For same error repeated (e.g. : included ), penalise
once then FT.
6 (b) (ii) • Any example of one complete record / row 1 Accept any sensible data for new record as long as
from the table given 4 distinct items of data given.
• Any example of one complete record / row
that could potentially be added to the table Allow field names with data.
Ignore order of data. Ignore case / spelling. Ignore
data types
Do not allow definition of a record.
6 (b) (iii) • Stage: String 2 Accept equivalent data types, including those that
• SetLength: Real // Float may be common in databases such as :
• String = text / varchar / char etc
• Real / float = decimal / single / double /
numeric etc
6 (c) (i) • Function definition for 4 Section B so must be high level code. Do not accept
calculatePrice() x for multiplication. Do not accept spaces in function,
• … with parameter that is not overwritten variable or parameter names if clearly obvious.
• Calculate price based on multiplying
parameter (if present) by 60 … Example code
function calculatePrice(num)
• …always return calculated price
price = num * 60
return price
endfunction
All code must be within function definition (if present).
BP3 – if no parameter present, allow multiplying
by sensible value (e.g. input value). FT
overwriting parameter.
BP4 must be return. Do not credit output/print. Value
returned can be with or without £ sign and other text.
FT for BP4 if sensible attempt made at calculation.
Accept multiple parameters passed in. Ignore
superfluous code
Accept returning by assigning to function name (e.g.
calculatePrice = price ), some languages
such as VB do this.
6 (c) (ii) • CalculatePrice(3) called… 25 2 Example code
• … return value assigned to totalPrice totalPrice = calculatePrice(3)
Do not accept == for assignment
Allow FT to BP2 only if sensible attempt at BP1
(e.g. missing/wrong parameter)
Allow multiple values passed in as long as 3 is one
of the values.
Do not accept definitions of a function – must be
calling the existing function.
Penalise spaces in variable / function name only if
clearly obvious.
Ignore superfluous code. Ignore case.
6 (d) (i) • Count initially set to 0 4 Example
• count increases to 10, 24, 30 and no other
changes
• x goes from 0, 1, 2 (, 3) and no other
changes.
• 30 output and no other output.
Ignore line numbers - not required. Mark order of
values.
Values can be repeated in count and x columns,
look at changes.
FT for BP4 if incorrect answer calculated but
output. Allow last value of count calculated to be
output for the mark.
Give BOD for “-“, “nothing”, etc as extra in output
column. Do not accept print(30) or equivalent
for output.
Question Answer 27 Mark Guidance
6 (d) (ii) • Line 02 2 Must use x as counter variable.
• For x = 0 to 4
Accept rewrites in other languages
BOD 0 to 5 / range(5) etc
Accept other changes that implement the change
successfully e.g. using length of actNumbers
6 (d) (iii) • print("The total act count is " 1 Allow other concatenation operators e.g. & (VB),
+ count) dot (PHP, Rust), double dot (Lua), etc. Allow
comma. Must have some form of separator.
Ignore spacing. Ignore case. Ignore casting.
Allow other commands that are equivalent to
print (e.g. echo, output, etc)
Allow multiple print statements. Allow multiple lines
of code that achieve the outcome.
Allow string interpolation or language specific
examples that will achieve this (e.g. f strings in
Python, use of $ before variables inside strings in
PHP). Both of the following and examples like this
are OK :
• print("The total act count is {count}")
• print("The total act count is $count")
6 (e) • input and store/use number of tickets 6 Allow any suitable confirmation message for BP3
needed (booked / not enough) but must be right way around.
• Check if enough tickets left…
BP2 must allow tickets to be booked when exact
• …sensible confirmation message output
number remain (e.g. 5 tickets needed and 5 remaining).
correctly for both booked and no tickets Check comparison operator does not exclude this.
available
• …tickets variable updated correctly BP3 and 4 dependent on BP2. If BP2 incorrect / not
• Attempt at iteration… given but reasonable attempt (e.g. checking if tickets
• …repeat all above that has been bigger than 0) allow FT for BP3/4.
attempted while tickets > 0 // while tickets
!= 0 // until tickets <=0 // until tickets = 0 Any attempt at loop means giving BP5
BP6 must not repeatedly reset tickets to 500. BP6 must
include repeated input (if present).
Ignore superfluous code.
Example code
tickets = 500
while tickets > 0
num = input("enter num tickets")
if tickets >= num then
print("tickets booked")
tickets = tickets - num
else
print("not enough tickets")
endif
endwhile
How to answer it
Rockfest Ticketing & Schedule System
What this question tests
- Inputs, Variables & Selection: Storing input strings and constructing relational IF...ELSE branches.
- SQL & Database Concepts: Correct syntax ( SELECT...FROM...WHERE ), records/rows, and appropriate data types.
- Subprograms: Declaring a function with parameters, returning calculated values, and calling functions correctly.
- Iteration & Arrays: Tracing 1D array traversals via trace tables and updating loop termination boundaries.
- Complex Algorithm Design: Writing a running-total loop using condition-controlled iteration ( WHILE ) with stock validation.
Part (a) — Password Inputs & Verification
Sub-parts (i) and (ii) • Total: 4 Marks
✅ Correct Answers
(i) [1 Mark] Select 3rd box:
passA = input("enter your password") passB = input("enter your password again")(ii) [3 Marks] Selection Algorithm:
if passA == passB then print("passwords match") else print("passwords do not match") endif🧠 Exam Technique & Mark Scheme Breakdown
- Mark 1: Comparing passA and passB for equality (use == or = ).
- Mark 2: Correct output string when True ( "passwords match" ).
- Mark 3: Correct output string when False ( "passwords do not match" ).
- Flowcharts are also accepted (diamond for decision, parallelograms for I/O).
❌ Common Errors
- Tick-box trap: In (i), picking box 4 where variable names are in quotation marks ( "passA" = ... ), which creates invalid syntax.
- In (ii), confusing assignment ( = ) with comparison ( == ) in Python answers.
- Typing errors in output strings (missing letters, case inconsistency).
💡 Key Knowledge
Variable assignment always follows the format variable = value . The left side must be an unquoted identifier, while the right side is the expression or function that produces the value.
Part (b) — Databases & SQL
Sub-parts (i), (ii) and (iii) • Total: 7 Marks
✅ Correct Answers
(i) Refined SQL [4 Marks]:
SELECT ActID, Stage FROM TblMusic WHERE Day = "Saturday"(ii) Example Record [1 Mark]:
1, Platinum, Saturday, 0.5 (or any valid row from the table, or a new complete 4-item record).
(iii) Data Types [2 Marks]:
- Stage : String (or Text / Varchar)
- SetLength : Real (or Float / Decimal)
📐 Identifying the 4 SQL Errors in (b)(i)
- Missing Comma: Changed ActID AND Stage to ActID, Stage . Fields in SELECT are comma-separated.
- Wrong Table Name: Changed TblActs to TblMusic .
- Invalid Clause: Changed IF to WHERE for filtering records.
- Missing Quotes: Changed Saturday to "Saturday" (strings in SQL require delimiters).
Part (c) — Functions: Definition & Calling
Sub-parts (i) and (ii) • Total: 6 Marks
✅ Correct Code
(i) Function Definition [4 Marks]:
function calculatePrice(numTickets) price = numTickets * 60 return price endfunction(ii) Calling the Function [2 Marks]:
totalPrice = calculatePrice(3)🧠 Mark Scheme Breakdown
Part (i) [4 Marks]:
- Mark 1: Function header named calculatePrice() .
- Mark 2: Includes a parameter that is not overwritten inside the body.
- Mark 3: Correct multiplication calculation ( parameter * 60 ).
- Mark 4: Uses keyword return to output the calculated value.
Part (ii) [2 Marks]:
- Mark 1: Calling calculatePrice(3) passing 3 as an argument.
- Mark 2: Assigning result directly to totalPrice .
❌ Common Student Mistakes
- Using print() instead of return in part (i). Functions return values; procedures output or perform actions without returning.
- Using an 'x' for multiplication ( num x 60 ) instead of an asterisk ( * ). Section B requires high-level code.
- In (ii), redefining the whole function or using double equals ( totalPrice == calculatePrice(3) ).
💡 Functions vs Procedures
A function always returns a value back to the line of code that called it. A parameter is a variable inside the function header that receives a value when the function is called.
Part (d) — Array Iteration, Tracing & Formatting
Sub-parts (i), (ii) and (iii) • Total: 7 Marks
📐 (i) Trace Table [4 Marks]
Array elements: actNumbers = [10, 14, 6]
| Line number | count | x | Output |
|---|---|---|---|
| 01 | 0 | ||
| 02 | 0 | ||
| 03 | 10 | ||
| 02 | 1 | ||
| 03 | 24 | ||
| 02 | 2 | ||
| 03 | 30 | ||
| 05 | 30 |
✅ (ii) Array Extension [2 Marks]
New array has 5 items (indexes 0 to 4):
Line number: 02
Updated code: for x = 0 to 4
(Python equivalent: for x in range(5): or for x in range(0, 5): )
✅ (iii) Output Concatenation [1 Mark]
New line 05:
print("The total act count is " + count)Also accepted: comma separation print("The total act count is ", count) or string casting/f-strings.
Part (e) — While Loop Ticketing Algorithm
Total: 6 Marks
✅ Model Solution (OCR Exam Reference Language)
tickets = 500 while tickets > 0 num = input("Enter number of tickets to buy: ") if tickets >= num then print("Tickets booked") tickets = tickets - num else print("Not enough tickets") endif endwhile🧠 6-Mark Breakdown
- Input: Prompt and store/use the number of tickets wanted.
- Condition Check: Check if enough tickets are available ( tickets >= num ). Must allow booking the exact remaining tickets!
- Output Messages: Sensible messages for both success and failure branches.
- Update Stock: Decrement tickets on success ( tickets = tickets - num ).
- Iteration Attempt: Loop structure present.
- Correct Termination: Repeat until no tickets are left ( while tickets > 0 or until tickets <= 0 ). Never reset tickets to 500 inside the loop!
❌ Top Traps in Algorithm Questions
- Off-by-one comparison: Using if tickets > num instead of >= . If there are 2 tickets left and a customer wants 2, they must be allowed to buy them!
- Variable reset: Placing tickets = 500 inside the loop body, which resets the stock on every transaction.
- Decrementing unconditionally: Subtracting num from tickets even when there were not enough tickets available.
Topics
2.1 Algorithms · 2.2 Programming fundamentals · 2.1.2 Designing, creating and refining algorithms · 2.2.1 Programming fundamentals · 2.2.2 Data types · 2.2.3 Additional programming techniques
Question and mark scheme from the OCR GCSE Computer Science examination, Computational thinking, algorithms and programming (02), June 2025. QuestionVault is an independent revision resource; questions remain the copyright of the awarding body.