Paper 2 Revision Booklet 2
Paper 2 Revision Booklet 2
hexadecimal number. E.g. HEX(10) would return “A”, HEX(15) would return “F”.
Write an algorithm, using the subroutine HEX(), to convert any whole decimal number between 0 and 255 into a
2 digit hexadecimal number.
[4]
© OCR 2024. You may photocopy this page. 1 of 265 Created in ExamBuilder
2 Complete the truth table below for the Boolean statement p = NOT (A AND B).
[2]
3(a) Heath is researching how long, to the nearest minute, each student in his class spends playing computer games
in one week (Monday to Friday). He is storing the data in a 2D array.
For example, student 1, on Monday (day 0), played 30 minutes of computer games.
Heath wants to output the number of minutes student 3 played computer games on Wednesday (day 2). He
writes the code:
print (hoursPlayed[3,2])
(i) Write the code to output the number of minutes student 0 played computer games on Wednesday.
[1]
print (hoursPlayed[2,1])
© OCR 2024. You may photocopy this page. 2 of 265 Created in ExamBuilder
[1]
[1]
(iv) Write an algorithm to output the total number of minutes student 0 played computer games from Monday
(day 0) to Friday (day 4).
[3]
© OCR 2024. You may photocopy this page. 3 of 265 Created in ExamBuilder
(b) Heath has the day of the week stored as a number e.g. 0 = Monday, 1 = Tuesday.
Write a sub-program that takes the number as a parameter and returns the day of the week as a string.
[5]
© OCR 2024. You may photocopy this page. 4 of 265 Created in ExamBuilder
(c) Heath needs to work out the average number of minutes spent playing computer games each day for the class,
which contains 30 students. Write an algorithm to output the average number of minutes the whole class spends
playing computer games each day.
[8]
© OCR 2024. You may photocopy this page. 5 of 265 Created in ExamBuilder
4(a) Willow has created a hangman program that uses a file to store the words the program can select from. A
sample of this data is shown in Fig. 3.
Show the stages of a bubble sort when applied to data shown in Fig. 3.
[4]
(b)
A second sample of data is shown in Fig. 4.
Show the stages of a binary search to find the word ‘zebra’ when applied to the data shown in Fig. 4.
[4]
© OCR 2024. You may photocopy this page. 6 of 265 Created in ExamBuilder
5(a) Johnny is writing a program to create usernames. The first process he has developed is shown in the flowchart
in Fig. 1.
For example, using the process in Fig. 1, Tom Ward's user name would be TomWa.
State, using the process in Fig. 1, the username for Rebecca Ellis.
[1]
© OCR 2024. You may photocopy this page. 7 of 265 Created in ExamBuilder
(b) Johnny has updated the process used to create usernames as follows:
If the person is male, then their username is the last 3 letters of their surname and the first 2 letters of their
first name.
If the person is female, then their username is the first 3 letters of their first name and the first 2 letters of
their surname.
• What would be the username for a male called Fred Biscuit using the updated process?
[1]
• Write an algorithm for Johnny to output a username using the updated process.
[6]
© OCR 2024. You may photocopy this page. 8 of 265 Created in ExamBuilder
6 Hamish stores confidential documents on his laptop.
If unauthorised access does occur, Hamish would like to use encryption to add another layer of protection to his
documents.
[2]
This Caesar cipher moves each letter of the alphabet one place to the right.
The following table shows the original letters in the first row, and the new letters in the second row.
The following pseudocode algorithm takes a string of uppercase letters as input and uses the Caesar cipher
to encrypt them.
Function Description
© OCR 2024. You may photocopy this page. 9 of 265 Created in ExamBuilder
ASC(character) Returns the ASCII value for character e.g.
ASC("A") returns 65
CHR(ASCIIvalue) Returns the single character for ASCIIvalue e.g.
CHR(65) returns "A"
subString(Value, Number) Returns the Number of characters starting at
position Value (where 0 is the first character)
(iii) The algorithm needs adapting. An extra line (line 12) is needed to output the encrypted message.
[1]
© OCR 2024. You may photocopy this page. 10 of 265 Created in ExamBuilder
7(a) A programmer creates an algorithm using a flow chart.
Complete the table to give the output when each of the following set of values are input into the algorithm as X
and Y.
© OCR 2024. You may photocopy this page. 11 of 265 Created in ExamBuilder
Input value of X Input value of Y Output
15 10
6 5
2 3
12 2
[4]
(b) Write this algorithm using pseudocode.
[6]
© OCR 2024. You may photocopy this page. 12 of 265 Created in ExamBuilder
(c) An algorithm is written in a high‐level language. The high level code must be translated into machine code before
a computer processor can execute it.
Describe two methods of translating high level code into machine code.
[4]
© OCR 2024. You may photocopy this page. 13 of 265 Created in ExamBuilder
8(a) Louise writes a program to work out if a number entered by the user is odd or even. Her first attempt at this
program is shown.
[1]
(ii) Give a corrected version of line 02 that fixes the logic error.
[1]
[1]
(ii) Give a corrected version of line 05 that fixes the syntax error.
[1]
© OCR 2024. You may photocopy this page. 14 of 265 Created in ExamBuilder
9(a) Elliott plays football for OCR FC. He wants to create a program to store the results of each football match they
play and the names of the goal scorers. Elliott wants individual players from the team to be able to submit this
information.
[2]
(ii) Give one example of how abstraction could be used when developing this program.
[1]
(b) The number of goals scored in each football match is held in an array called goals. An example of this array is
shown.
goals = [0, 1, 3, 0, 4, 5, 2, 0, 2, 1]
Complete the following pseudocode for an algorithm to count up how many matches with 0 goals are stored in
the array and then print out this value.
01 nogoalscount = 0
02 for count = 0 to (goals.length-1)
03 if goals[…………………………] == 0 then
04 nogoalscount ……………………………………………………
05 endif
06 next count
07 print(……………………………………………)
[3]
© OCR 2024. You may photocopy this page. 15 of 265 Created in ExamBuilder
10(a) OCR Land is a theme park aimed at children and adults. Entrance tickets are sold online. An adult ticket to OCR
Land costs £19.99, with a child ticket costing £8.99. A booking fee of £2.50 is added to all orders.
A function, ticketprice(), takes the number of adult tickets and the number of child tickets as parameters. It
calculates and returns the total price to be paid.
© OCR 2024. You may photocopy this page. 16 of 265 Created in ExamBuilder
[6]
(ii) Tick (✓) one box to identify the data type of the value returned from the function ticketprice(), justifying
your choice.
Justification
[2]
© OCR 2024. You may photocopy this page. 17 of 265 Created in ExamBuilder
(b) OCR Land regularly emails discount codes to customers. Each discount code includes a check digit as the last
character.
(i) Give one benefit of using a check digit for the discount code.
[1]
(i) State one reason why a binary search would not be able to be used with this data.
[1]
(ii) Give the name of one searching algorithm that would be able to be used with this data.
[1]
© OCR 2024. You may photocopy this page. 18 of 265 Created in ExamBuilder
(d) OCR Land keeps track of the size of queues on its rides by storing them in an array with the identifier
queuesize. It uses the following bubble sort algorithm to put these queue sizes into ascending numerical order.
01 swaps = True
02 while swaps
03 swaps = False
04 for p = 0 to queuesize.length-2
05 if queuesize[p] > queuesize[p+1] then
06 temp = queuesize[p]
07 queuesize[p] = queuesize[p+1]
08 queuesize[p+1] = temp
09 swaps = True
10 endif
11 next p
12 endwhile
(i) Explain the purpose of the Boolean variable swaps in this bubble sort algorithm.
[2]
© OCR 2024. You may photocopy this page. 19 of 265 Created in ExamBuilder
[2]
(iii) Describe one way that the maintainability of this algorithm could be improved.
[2]
(iv) Give the names of two other sorting algorithms that could be used instead of bubble sort.
[2]
© OCR 2024. You may photocopy this page. 20 of 265 Created in ExamBuilder
(e) One ride in OCR Land has a minimum height of 140 cm to ride alone or 120 cm to ride with an adult.
© OCR 2024. You may photocopy this page. 21 of 265 Created in ExamBuilder
© OCR 2024. You may photocopy this page. 22 of 265 Created in ExamBuilder
[8]
© OCR 2024. You may photocopy this page. 23 of 265 Created in ExamBuilder
11(a) A program uses a file to store a list of words that can be used in a game.
Show the stages of a bubble sort when applied to data shown in Fig. 3.
[4]
© OCR 2024. You may photocopy this page. 24 of 265 Created in ExamBuilder
(b) A second sample of data is shown in Fig. 4.
Show the stages of a binary search to find the word zebra using the data shown in Fig. 4.
[4]
© OCR 2024. You may photocopy this page. 25 of 265 Created in ExamBuilder
12(a) The program should only allow values from 0 to 300 inclusive as valid inputs. If the data entered breaks this
validation rule, an error message is displayed.
(i) Complete the following program to output "Invalid input" if the data does not meet the validation rule.
endif [3]
(ii) Complete the following test plan for the program in (i).
© OCR 2024. You may photocopy this page. 26 of 265 Created in ExamBuilder
(b) The following program uses a condition-controlled loop.
x = 15
y = 0
while x > 0
y = y + 1
x = x – y
endwhile
print(y)
x y output
[4]
© OCR 2024. You may photocopy this page. 27 of 265 Created in ExamBuilder
(c) A teacher writes an algorithm to store the name of the game a student plays each night (for example "OCR Zoo
Simulator").
valid = false
while(valid == false)
gamesPlayed = gameName.upper
valid = true
else
endif
endwhile
The algorithm needs testing to make sure the IF-ELSE statement works correctly.
Identify two different pieces of test data that can be used to test different outputs of the algorithm. Give the
output from the program for each piece of test data.
Test data 1
Expected output
Test data 2
Expected output
[4]
© OCR 2024. You may photocopy this page. 28 of 265 Created in ExamBuilder
(d) A teacher researches the length of time students spend playing computer games each day.
The teacher asks students how long they spend completing homework. Students answer in minutes and hours
(for example 2 hours 15 minutes).
The teacher would like to create an algorithm that will display students’ inputs in minutes only.
(i) Identify the input and output required from this algorithm.
Input
Output
[2]
(ii) A program is created to convert hours and minutes into a total number of minutes.
(iii) The following flowchart outputs a message depending on how long each person has spent playing computer
© OCR 2024. You may photocopy this page. 29 of 265 Created in ExamBuilder
games.
[4]
© OCR 2024. You may photocopy this page. 30 of 265 Created in ExamBuilder
13(a) A school uses a mobile phone app to allow parents to book appointments for parents’ evenings.
Parents must log in before they can use the system. They then choose to book a new appointment, view all
appointments already made or update their personal details. If parents choose to view their appointments, they
can either view them on-screen or print them off.
A structure diagram has been used to design the mobile phone app.
Write one letter from the following table in each space to complete the structure diagram.
Letter Task
A Book new appointment
B Check attendance of child
C Update personal details
D View appointments on-screen
E Log out of the system
F Print a paper copy of appointments
[4]
© OCR 2024. You may photocopy this page. 31 of 265 Created in ExamBuilder
(b) At the parents’ evening, each parent can book up to five appointments with teachers.
Appointments for one student are stored in a one-dimensional array with the identifier appointments.
In the array, each element is either the name of a teacher or an empty string where no appointment has been
made.
array appointments = ["Miss E", "", "Mr C", "Mr B", ""]
The following code shows an algorithm to count up how many empty slots remain in the array and output this
value.
01 for i = 0 to 4
02 empty = 0
03 if appointments[i] == "" then
04 empty = empty + 1
05 endif
06 next i
07 print("empty")
[1]
(ii) Identify the line number of two logic errors in the code above and explain why each is an error.
Logic error 1
Explanation
© OCR 2024. You may photocopy this page. 32 of 265 Created in ExamBuilder
Logic error 2
Explanation
[4]
(c) Each teacher has the assessment grades for each student. These grades are stored in numerical order.
2 3 4 5 6 7 8
Show the steps that a binary search would take to check whether the student has achieved a grade 7 in any
assessment.
[4]
© OCR 2024. You may photocopy this page. 33 of 265 Created in ExamBuilder
(ii) Explain how a binary search would determine that a value does not appear in a given array.
[2]
[1]
© OCR 2024. You may photocopy this page. 34 of 265 Created in ExamBuilder
14 A cinema uses the following criteria to decide if a customer is allowed to see a film that has a 15 rating:
Customers have to be 15 years of age or older to see the film. They also need to either have a ticket or
have the money to buy a ticket.
The table shows the inputs to the system that will output whether the customer can watch the film.
[3]
© OCR 2024. You may photocopy this page. 35 of 265 Created in ExamBuilder
15(a) A car dealership uses a computer system to record details of the cars that it has for sale. Each car has a make,
model, age and number of miles driven.
Each car is given a star rating of 1 to 5, based on the age of the car and the number of miles it has been driven.
This rating is recorded in the computer system.
[1]
(ii) Give one example of how abstraction has been used in the design of this star rating system.
[1]
(iii) Explain how authentication could be used as part of the defensive design considerations for this computer
system.
[2]
(b) The car dealership only sells cars that have fewer than 10 000 miles and are 5 years old or less.
• ask the user to enter the number of miles and the age of a car
• validate the input to check that only sensible values that are in the given range are entered
• output True if valid data has been entered or False if invalid data has been entered.
© OCR 2024. You may photocopy this page. 36 of 265 Created in ExamBuilder
[5]
(ii) The validation routine from part (i) must be tested with normal, erroneous and boundary test data.
Miles Age
Normal
Erroneous
Boundary
[3]
[1]
© OCR 2024. You may photocopy this page. 37 of 265 Created in ExamBuilder
(c) The car dealership sells electric cars, which require charging before they can be driven. Charging the battery by
1% takes 10 minutes.
For example, a battery has 80% charge. It would take 200 minutes, or 3 hours and 20 minutes to charge to
100%.
© OCR 2024. You may photocopy this page. 38 of 265 Created in ExamBuilder
[6]
16(a) OCR Tech is an online shop that sells electronics such as TVs and game consoles.
The following flowchart shows an algorithm to calculate the price of an item during a sale period.
© OCR 2024. You may photocopy this page. 39 of 265 Created in ExamBuilder
(i) Complete the following test plan for the algorithm.
100 Boundary
150 Normal
200 Boundary
250 Normal
© OCR 2024. You may photocopy this page. 40 of 265 Created in ExamBuilder
[3]
[6]
© OCR 2024. You may photocopy this page. 41 of 265 Created in ExamBuilder
(b) An item is classified as "In demand" if OCR Tech have between 5 and 25 inclusive in stock.
A program is written that allows the user to input the current stock level and output whether the item is in
demand or not.
Refine the program to correct the errors and write the refined version of the program.
[5]
© OCR 2024. You may photocopy this page. 42 of 265 Created in ExamBuilder
17(a) Complete the truth table in Fig. 1 for the Boolean statement P = NOT(A AND B).
A B P
0 0 1
0 1 ..................
1 0 ..................
1 1 0
Fig. 1
[2]
© OCR 2024. You may photocopy this page. 43 of 265 Created in ExamBuilder
(b) Tick (✓) one box to identify the correct logic diagram for P = NOT(A AND B).
[1]
© OCR 2024. You may photocopy this page. 44 of 265 Created in ExamBuilder
18(a) A program needs to perform the following tasks:
.....................................
else
.....................................
endif
[4]
© OCR 2024. You may photocopy this page. 45 of 265 Created in ExamBuilder
(b) A second program needs to perform the following tasks:
[5]
19(a) A program creates usernames for a school. The first design of the program is shown in the flowchart in Fig. 2.
© OCR 2024. You may photocopy this page. 46 of 265 Created in ExamBuilder
Fig. 2
For example, using the process in Fig. 2, Tom Ward’s username would be TomWa.
State, using the process in Fig. 2, the username for Rebecca Ellis.
[1]
• If the person is a teacher, their username is the last 3 letters of their surname and then the first 2 letters of
their first name.
• If the person is a student, their username is the first 3 letters of their first name and then the first 2 letters of
their surname.
© OCR 2024. You may photocopy this page. 47 of 265 Created in ExamBuilder
(i) What would be the username for a teacher called Fred Biscuit using the updated process?
[1]
(ii) Write an algorithm for the updated program design shown in (i).
[6]
© OCR 2024. You may photocopy this page. 48 of 265 Created in ExamBuilder
20(a) A computer game is written in a high-level programming language.
State why the computer needs to translate the code before it is executed.
[1]
Describe two differences between how a compiler and an interpreter would translate the code.
[4]
Ali’s computer uses virtual memory. Ali has written two procedures to help himself understand how virtual
memory works.
Write the letter of the missing statements from the table in the correct place to complete the algorithms. Not all
statements are used, and some statements might be used more than once.
procedure storeData()
© OCR 2024. You may photocopy this page. 49 of 265 Created in ExamBuilder
move data from RAM to .........................
endif
.........................
procedure accessData()
endif
endif
endprocedure
Letter Statement
A Secondary storage
B NOT
C Full
D endfunction
E Empty
F endprocedure
G AND
H RAM
[6]
© OCR 2024. You may photocopy this page. 50 of 265 Created in ExamBuilder
22 The following table contains several definitions of terms that are used in Computer Science.
Letter Definition
A Cleaning up data entered by removing non-standard characters
B Hiding or removing irrelevant details from a problem to reduce complexity
C Checking that the user is allowed to access the program
D Breaking a complex problem down into smaller problems
E Repeating elements of a program
F Converting one data type to another, for example converting an integer to a real number
Write the letter of the definition that matches each keyword in each space.
Decomposition ..................
Abstraction ..................
Casting ..................
[4]
© OCR 2024. You may photocopy this page. 51 of 265 Created in ExamBuilder
23(a) The algorithm for one section of a vending machine program is shown in pseudocode.
venditem()
giveChange(money – price)
else
endif
[1]
(ii) State how many parameters are passed into the giveChange() subroutine.
[1]
Users insert coins into the vending machine and then enter the two character item code of their selection. If the
user has inserted enough money, the vending machine will release the chosen item and output any change
required. If the user enters an invalid item code then a suitable error message is displayed.
© OCR 2024. You may photocopy this page. 52 of 265 Created in ExamBuilder
[5]
© OCR 2024. You may photocopy this page. 53 of 265 Created in ExamBuilder
(c) When writing the program for the vending machine, maintainability was considered.
(i) Identify two ways that the program in the part above has been made more maintainable.
[2]
(ii) Give one additional way that the maintainability of the program can be improved.
[1]
© OCR 2024. You may photocopy this page. 54 of 265 Created in ExamBuilder
24(a) The following names of students are stored in an array with the identifier studentnames.
Describe the steps that a linear search would take to find Anna in studentnames
[4]
© OCR 2024. You may photocopy this page. 55 of 265 Created in ExamBuilder
(b) The names of students are sorted into ascending alphabetical order using an insertion sort.
Complete the following diagram to show the stages an insertion sort would take to complete this task.
Each row represents one pass of the insertion sort algorithm. You may not need to use all empty rows.
[5]
© OCR 2024. You may photocopy this page. 56 of 265 Created in ExamBuilder
(c) A school uses the array to call an attendance register every morning.
[6]
© OCR 2024. You may photocopy this page. 57 of 265 Created in ExamBuilder
25(a) An insertion sort is used to put the following words into ascending alphabetical order.
Tick (✓) one box in each row to identify whether each statement about the insertion sort is true or false.
Explain how a binary search would be used to try to find whether the word “house” appears in this list.
[4]
© OCR 2024. You may photocopy this page. 58 of 265 Created in ExamBuilder
26 Taylor is writing an algorithm to record the results of an experiment.
Taylor needs to be able to enter a numeric value which is added to a total which initially starts at 0.
Give two computational thinking techniques that Taylor has used, describing how they have been used.
[4]
[1]
© OCR 2024. You may photocopy this page. 59 of 265 Created in ExamBuilder
(b) State the name of each of the following computational thinking techniques.
[2]
28(a) A fast food restaurant offers half-price meals if the customer is a student or has a discount card. The offer is not
valid on Saturdays.
The restaurant needs an algorithm designing to help employees work out if a customer can have a half price
meal or not. It should:
© OCR 2024. You may photocopy this page. 60 of 265 Created in ExamBuilder
[5]
© OCR 2024. You may photocopy this page. 61 of 265 Created in ExamBuilder
(b) The restaurant adds a service charge to the cost of a meal depending on the number of people at a table. If
there are more than five people 5% is added to the total cost of each meal.
Customers can also choose to leave a tip, this is optional and the customer can choose between a percentage of
the cost, or a set amount.
Identify all the additional inputs that will be required for this change to the algorithm.
[2]
29(a) A program stores the following list of positive and negative numbers. The numbers need sorting into ascending
order using a merge sort.
Complete the merge sort of the data by showing each step of the process.
© OCR 2024. You may photocopy this page. 62 of 265 Created in ExamBuilder
[3]
© OCR 2024. You may photocopy this page. 63 of 265 Created in ExamBuilder
(b) Once a list of numbers are in order, a binary search can be run on the data.
Describe the steps a binary search will follow to look for a number in a sorted list.
[4]
Describe the steps a linear search would follow when searching for a number that is not in the given list.
[2]
© OCR 2024. You may photocopy this page. 64 of 265 Created in ExamBuilder
30 Jack is writing a program to add up some numbers. His first attempt at the program is shown.
a = input(“Enter a number”)
b = input(“Enter a number”)
c = input(“Enter a number”)
d = input(“Enter a number”)
e = input(“Enter a number”)
f = (a + b + c + d + e)
print(f)
Jack decides to improve his program. He wants to be able to input how many numbers to add together each time
the algorithm runs, and also wants it to calculate and display the average of these numbers.
Write an algorithm to:• ask the user to input the quantity of numbers they want to enter and read this value 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.
© OCR 2024. You may photocopy this page. 65 of 265 Created in ExamBuilder
[6]
31(a) Customers at a hotel can stay between 1 and 5 (inclusive) nights and can choose between a basic room or a
premium room.
When a new booking is recorded, the details are entered into a program to validate the values. The following
criteria are checked:
• firstName and surname are not empty
• room is either “basic” or “premium”
• nights is between 1 and 5 (inclusive).
If any invalid data is found “NOT ALLOWED” is displayed.
If all data is valid “ALLOWED” is displayed.
© OCR 2024. You may photocopy this page. 66 of 265 Created in ExamBuilder
(i) Complete the following program to validate the inputs.
stayComplete = False
© OCR 2024. You may photocopy this page. 67 of 265 Created in ExamBuilder
[5]
(ii) Complete the following test plan to check whether the number of nights is validated correctly.
© OCR 2024. You may photocopy this page. 68 of 265 Created in ExamBuilder
(b) A Basic room costs £60 each night. A Premium room costs £80 each night.
(i) Create a function, newPrice(), that takes the number of nights and the type of room as parameters,
calculates and returns the price to pay.
[4]
(ii) Write program code, that uses newPrice(), to output the price of staying in a Premium room for 5 nights.
© OCR 2024. You may photocopy this page. 69 of 265 Created in ExamBuilder
You must use either:
[3]
© OCR 2024. You may photocopy this page. 70 of 265 Created in ExamBuilder
(c) A hotel has nine rooms that are numbered from room 0 to room 8.
The number of people currently staying in each room is stored in an array with the identifier room.
Array room
Index 0 1 2 3 4 5 6 7 8
Data 2 1 3 2 1 0 0 4 1
The following program counts how many people are currently staying in the hotel.
for count = 1 to 8
total = 0
next count
print(total)
Describe how the program can be refined to remove these logic errors.
[2]
© OCR 2024. You may photocopy this page. 71 of 265 Created in ExamBuilder
(d) A hotel car park charges £4 per hour. If the car is electric, this price is halved to £2 per hour.
• take as input the number of hours the user has parked and whether their car is electric or not
• calculate and output the total price
• repeat continually until the user enters 0 hours.
© OCR 2024. You may photocopy this page. 72 of 265 Created in ExamBuilder
[6]
Tick (✓) one box in each row to identify whether each statement describes a low-level programming language or
a high-level programming language.
Write pseudocode to add the integers stored in num1 and num2. Store the result in a variable with the identifier
total
[1]
© OCR 2024. You may photocopy this page. 73 of 265 Created in ExamBuilder
(c) Three incomplete pseudocode algorithms are given with a description of the purpose of each algorithm.
print(12 ……………… 2)
[1]
number = 53
print("Even number")
else
print("Odd number")
endif
[1]
measurement1 = 300
measurement2 = 100
© OCR 2024. You may photocopy this page. 74 of 265 Created in ExamBuilder
(d) Read the following pseudocode algorithm:
01 start = 3
02 do
03 print(start)
04 start = start - 1
05 until start == -1
06 print("Finished")
[3]
© OCR 2024. You may photocopy this page. 75 of 265 Created in ExamBuilder
33(a) An insertion sort is one type of sorting algorithm.
A student has written a pseudocode algorithm to perform an insertion sort on a 1D array names.
pos = count
temp = names[pos]
names[pos] = names[pos – 1]
names[pos – 1] = temp
pos = pos – 1
endwhile
next count
Describe the purpose of the variable temp in the insertion sort pseudocode algorithm.
[2]
© OCR 2024. You may photocopy this page. 76 of 265 Created in ExamBuilder
(b) An insertion sort contains a nested loop; a loop within a loop. In this pseudocode algorithm the outer loop is a
count-controlled loop and the inner loop is a condition-controlled loop.
[2]
(i) Describe one difference between an insertion sort and a bubble sort.
[2]
(ii) Describe two similarities between an insertion sort and a bubble sort.
[2]
© OCR 2024. You may photocopy this page. 77 of 265 Created in ExamBuilder
[6]
© OCR 2024. You may photocopy this page. 78 of 265 Created in ExamBuilder
35(a) Heath is researching how long, to the nearest minute, each student in his class spends playing computer games
in one week (Monday to Friday). He is storing the data in a 2D array.
For example, student 1, on Monday (day 0), played 30 minutes of computer games.
[2]
(b)
(i) Identify a data type that could be used to store the number of minutes in this array.
[1]
[1]
© OCR 2024. You may photocopy this page. 79 of 265 Created in ExamBuilder
36(a) The area of a circle is calculated using the formula Π × r2, where Π is equal to 3.142 and r is the radius.
Finn has written a program to allow a user to enter the radius of a circle as a whole number, between 1 and 30,
and output the area of the circle.
[2]
(b)
(i) Identify one item in the program that could have been written as a constant.
[1]
(ii) Give one reason why you have identified this item as a constant.
[1]
© OCR 2024. You may photocopy this page. 80 of 265 Created in ExamBuilder
37 Elliott plays football for OCR FC. He wants to create a program to store the results of each football match they
play and the names of the goal scorers. Elliott wants individual players from the team to be able to submit this
information.
Describe two examples of defensive design that should be considered when developing this program.
[4]
© OCR 2024. You may photocopy this page. 81 of 265 Created in ExamBuilder
38 The symbol ^ is used for exponentiation.
Give the result of a^b when a = 3 and b = 2.
[1]
© OCR 2024. You may photocopy this page. 82 of 265 Created in ExamBuilder
39(a) The area of a circle is calculated using the formula π × r2 where π is equal to 3.142 and r is the radius.
A program is written to allow a user to enter the radius of a circle as a whole number between 1 and 30, then
calculate and output the area of the circle.
01 radius = 0
02 area = 0.0
03 radius = input("Enter radius")
04 if radius < 1 OR radius > 30 then
05 print("Sorry, that radius is invalid")
06 else
07 area = 3.142 * (radius ^ 2)
08 print (area)
09 endif
Explain, using examples from the program, two ways to improve the maintainability of the program.
[4]
(b) Identify two variables used in the program.
[2]
© OCR 2024. You may photocopy this page. 83 of 265 Created in ExamBuilder
(c)
(i) Identify one item in the program that could have been written as a constant.
[1]
(ii) Give one reason why you have identified this item as a constant.
[1]
(d) Tick (✓) one box in each row to identify whether each programming construct has or has not been used in the
program.
Selection
Iteration
[3]
40(a) A teacher researches the length of time students spend playing computer games each day.
Tick (✓) one box to identify the data type you would choose to store the data and explain why this is a suitable
data type.
Explanation:
[2]
© OCR 2024. You may photocopy this page. 84 of 265 Created in ExamBuilder
(b) Data for one week (Monday to Friday) is stored in a 2D array with the identifier minsPlayed.
The teacher wants to output the number of minutes Dan (column index 3) played computer games on
Wednesday (row index 2). The following code is written:
print(minsPlayed[3,2])
Write program code to output the number of minutes that Stuart played computer games on Friday.
[1]
© OCR 2024. You may photocopy this page. 85 of 265 Created in ExamBuilder
41 A cinema uses the following criteria to decide if a customer is allowed to see a film that has a 15 rating:
Customers have to be 15 years of age or older to see the film. They also need to either have a ticket or
have the money to buy a ticket.
The table shows the inputs to the system that will output whether the customer can watch the film.
The function freeseats() counts how many seats are available in each screen. The name of the screen is
passed in as a string parameter and the number of free seats is returned as an integer.
Write code using the function freeseats() to find the number of seats available in screen Red and assign this
to a variable with identifier redseats.
[2]
© OCR 2024. You may photocopy this page. 86 of 265 Created in ExamBuilder
42(a) OCR Tech is an online shop that sells electronics such as TVs and game consoles.
Items for sale are stored in the database table tblStock. An extract of this table is shown.
FROM tblStock
FROM table
FROM database
[3]
© OCR 2024. You may photocopy this page. 87 of 265 Created in ExamBuilder
(b) Customers can use a discount code to reduce the price of their purchase. Valid discount codes and their value
(in pounds) are stored in a global two-dimensional (2D) array with the identifier discount. The following table
shows part of this 2D array.
For example, discount[2,0] holds discount code BGF2 and discount[2,1] holds the discount of 15
pounds.
A function searches through the 2D array and applies the discount to the price. The price and discount code are
passed in as parameters. The algorithm design is not complete.
[5]
[2]
© OCR 2024. You may photocopy this page. 88 of 265 Created in ExamBuilder
(iii) Write a program that:
© OCR 2024. You may photocopy this page. 89 of 265 Created in ExamBuilder
[6]
43 The database table Results stores the results for each student in each of their chosen subjects.
Complete the SQL query to return all of the fields for the students who take Art.
SELECT
FROM
WHERE
[3]
© OCR 2024. You may photocopy this page. 90 of 265 Created in ExamBuilder
44 The following table contains several definitions of terms that are used in Computer Science.
Letter Definition
A Cleaning up data entered by removing non-standard characters
B Hiding or removing irrelevant details from a problem to reduce complexity
C Checking that the user is allowed to access the program
D Breaking a complex problem down into smaller problems
E Repeating elements of a program
F Converting one data type to another, for example converting an integer to a real number
(i) Write a pseudocode statement to assign the value 7.3 to a variable with the identifier timer
[1]
(ii) State the most appropriate data type for the variable timer.
[1]
© OCR 2024. You may photocopy this page. 91 of 265 Created in ExamBuilder
45 Dru writes the following program using a high-level language.
01 function newscore(a,b)
02 temp = a*b
03 temp = temp + 1
04 return temp
05 endfunction
06 score = 18
07 name = "Dru"
08 print (score)
09 print ("name")
10 print (newscore(score,2))
11 print (score)
The following table contains the program code for each line where this program outputs values.
09 print ("name")
10 print (newscore(score,2))
11 print (score)
[4]
© OCR 2024. You may photocopy this page. 92 of 265 Created in ExamBuilder
46(a) The vending machine stores the quantity of items available in a database table called ITEMS.
The current contents of ITEMS is shown:
Complete the following SQL statement to display the item code for all items that have fewer than 10 in stock.
SELECT
FROM
[4]
© OCR 2024. You may photocopy this page. 93 of 265 Created in ExamBuilder
(b) The vending machine can be in one of three states: on, off or suspended. A user can change the state of the
vending machine by using the following algorithm.
switch newstate:
case "on":
statevalue = 1
case "off":
statevalue = 2
case "suspended":
statevalue = 3
default:
print("Invalid state")
endswitch
Rewrite the algorithm to perform the same actions using IF statements in place of the switch statement.
[5]
© OCR 2024. You may photocopy this page. 94 of 265 Created in ExamBuilder
47 DIV and MOD are both operators used in computing-related mathematics.
[1]
[1]
© OCR 2024. You may photocopy this page. 95 of 265 Created in ExamBuilder
48 A program is being created to convert the data capacity of a storage device into a different measure.
The function, calculate(), takes the measurement (e.g. gigabytes) and the number (e.g. 2) as two
parameters. It then returns the value in bits. The function returns –1 if an invalid measurement was entered.
else
..................................................
endif
return ..................................................
endfunction [6]
© OCR 2024. You may photocopy this page. 96 of 265 Created in ExamBuilder
49(a) Taylor is writing an algorithm to record the results of an experiment.
Taylor needs to be able to enter a numeric value which is added to a total which initially starts at 0.
[6]
© OCR 2024. You may photocopy this page. 97 of 265 Created in ExamBuilder
(b) The input to the program could be an integer or real value.
(i) State what is meant by a real data type and give an example of this data type.
[2]
(ii) State what is meant by an integer data type and give an example of this data type.
[2]
(c) For the next part of the experiment, Taylor needs to be able to enter 10 values and count how many of the
values are over 50, outputting this value once all values have been entered.
© OCR 2024. You may photocopy this page. 98 of 265 Created in ExamBuilder
[5]
(ii) Write a pseudocode algorithm that uses iteration to allow Taylor to:
• enter 10 values
• count how many values are over 50
© OCR 2024. You may photocopy this page. 99 of 265 Created in ExamBuilder
• output the count of values over 50 after all 10 values are entered.
[5]
[1]
© OCR 2024. You may photocopy this page. 100 of 265 Created in ExamBuilder
(b) State the output from the following lines of program code.
(i) print(first.length)
[1]
[1]
(iii) print(3 ^ 2)
[1]
(c) Strings can be concatenated (joined together) using the + operator. For example, print("Maths " +
second) will output Maths is great
Use string manipulation with the variables first and/or second to produce the following output.
(i) great
[1]
(ii) Computer
[1]
[1]
© OCR 2024. You may photocopy this page. 101 of 265 Created in ExamBuilder
51(a) OCRBlocks is a game played on a 5 × 5 grid. Players take it in turns to place blocks on the board.
The board is stored as a two-dimensional (2D) array with the identifier gamegrid
Fig. 6.1 shows that players A and B have placed three blocks each so far.
Fig. 6.1
The function checkblock() checks whether a square on the board has been filled. When checkblock(4,2)
is called, the value "A" is returned.
function checkblock(r,c)
if gamegrid[r,c] == "A" or gamegrid[r,c] == "B" then
outcome = gamegrid[r,c]
else
outcome = "FREE"
endif
return outcome
endfunction
Give the returned value when the following statements are called.
© OCR 2024. You may photocopy this page. 102 of 265 Created in ExamBuilder
(b) State one feature of checkblock() that shows that it is a function and not a procedure.
[1]
[1]
(ii) Describe how validation could be added in to the checkblock() function to stop this error from occurring.
[3]
(d) Write an algorithm to allow player A to select a position for their next block on the game board.
• ask the player for the position of their block on the board
• use the checkblock() function to check if this position is free
• if the position is free, add the letter "A" to the position chosen in the gamegrid array
• if the position is not free, repeat the above steps until a free position is chosen.
© OCR 2024. You may photocopy this page. 103 of 265 Created in ExamBuilder
[6]
© OCR 2024. You may photocopy this page. 104 of 265 Created in ExamBuilder
52 Tick (✓) one box in each row to identify whether the OCR Reference Language code given is an example of
selection or iteration.
whilescore != 0
playgame()
endwhile
if playerHit() then
score = 0
endif
switch bonus:
case 0:
score = 9
case 1:
score = 7
case 2:
score = 5
endswitch
[4]
53 Each member of staff that works in a restaurant is given a Staff ID. This is calculated using the following
algorithm.
06 endwhile
07 print(“ID ” + staffID)
(i) Define the term casting and give the line number where casting has been used in the algorithm.
© OCR 2024. You may photocopy this page. 105 of 265 Created in ExamBuilder
Definition
Line number
[2]
(ii) Complete the following trace table for the given algorithm when the surname “Kofi” and the year 2021 are
entered.
[4]
54 Jack’s program uses the addition ( + ) arithmetic operator. This adds together two numbers.
(i) State the purpose of each of the arithmetic operators in the table.
[2]
© OCR 2024. You may photocopy this page. 106 of 265 Created in ExamBuilder
(ii) Complete the description of programming languages and translators by writing the correct term from the box
in each space.
Jack writes his program in a ........................................ language. This needs to be translated into assembly
One type of translator is an interpreter. This converts one line of code and then executes it, before moving to
the next line. It ........................................ when an error is found, and when corrected continues running from
A second type of translator is a compiler. This converts all of the code and produces an error report. The
[5]
55 Customers at a hotel can stay between 1 and 5 (inclusive) nights and can choose between a basic room or a
premium room.
firstName Amaya
surname Taylor-Ling
nights 3
room Premium
stayComplete False
© OCR 2024. You may photocopy this page. 107 of 265 Created in ExamBuilder
(i) State the most appropriate data type for the following fields:
Nights
Room
[2]
(ii) Give the name of one field that could be stored as a Boolean data type.
[1]
The following SQL statement is written to display all customer bookings that stay more than one night.
SELECT ALL
FROM TblBookings
IF Nights < 1
[4]
© OCR 2024. You may photocopy this page. 108 of 265 Created in ExamBuilder
56(a) OCR Security Services is a company that installs intruder alarm systems in commercial buildings.
The systems use a computer that is connected to the door sensors and window sensors.
Tick (✓) one box in each row to identify the most appropriate data type for each variable.
© OCR 2024. You may photocopy this page. 109 of 265 Created in ExamBuilder
(b) An alarm has an algorithm that decides whether to sound the alarm by checking the data that is stored in the
following three variables.
• SystemArmed
• DoorSensorActive
• WindowSensorActive
The alarm will only sound when the alarm has been activated and one or both of the door and window sensors
are activated. When the system needs to sound the alarm it calls the pre-written procedure SoundAlarm()
Write a program that checks the data in the variables and calls SoundAlarm() when appropriate.
[4]
(c) An alarm system has multiple sensors. Each type of sensor has a code. The code for each sensor is given in the
table:
Code Sensor
MS Motion sensor
DS Door sensor
WS Window sensor
© OCR 2024. You may photocopy this page. 110 of 265 Created in ExamBuilder
01 sensorType = input("Enter code of the type of sensor to reset")
02 if(CheckSensorCode(sensorType)) then
05 ResetSensor(sensorID)
06 endif
[1]
[1]
(iii) Identify the data type of the data returned by the function CheckSensorCode()
[1]
[1]
(v) Identify two programming constructs that have been used in the program.
2 [2]
© OCR 2024. You may photocopy this page. 111 of 265 Created in ExamBuilder
(d) An alarm system has a log that stores a record each time a sensor is triggered. This is called an event. The
record format is given in the table:
Fieldname Description
Date The date the event happened
SensorID The sensor that was activated
SensorType The type of sensor that was activated – Door, Motion or Window
Length The number of seconds the sensor was triggered (to the nearest second)
The log is stored in a database table called events. The current contents of events is shown:
Write an SQL statement to display the sensor IDs of the door sensors that have been triggered for more than 20
seconds.
[3]
(e) A program written in a high-level language is used to access the data from a database.
This program has a procedure, SaveLogs(), that stores the data to an external text file.
© OCR 2024. You may photocopy this page. 112 of 265 Created in ExamBuilder
• takes the string of data to be stored to the text file as a parameter
• takes the filename of the text file as a parameter
• stores the string of data to the text file.
[6]
© OCR 2024. You may photocopy this page. 113 of 265 Created in ExamBuilder
(f) OCR Security Services need to identify the total number of seconds the sensors have been activated on a
specific date.
The data from the database table events is imported into the program written in a highlevel programming
language.
The program stores the data in a two-dimensional (2D) string array with the identifier arrayEvents
(i) An array can only store data of one data type. Any non-string data must be converted to a string before
storing in the array.
[1]
© OCR 2024. You may photocopy this page. 114 of 265 Created in ExamBuilder
[6]
57 The area of a circle is calculated using the formula Π × r2, where Π is equal to 3.142 and r is the radius.
Finn has written a program to allow a user to enter the radius of a circle as a whole number, between 1 and 30,
and output the area of the circle.
© OCR 2024. You may photocopy this page. 115 of 265 Created in ExamBuilder
Explain, using examples from the program, two ways Finn can improve the maintainability of the program.
[6]
58 A teacher researches the length of time students spend playing computer games each day.
The teacher writes a program to add up and print out the total number of minutes student 2 played computer
games over 5 days (Monday to Friday).
total = 0
total = total + minsPlayed[2,0]
total = total + minsPlayed[2,1]
© OCR 2024. You may photocopy this page. 116 of 265 Created in ExamBuilder
total = total + minsPlayed[2,2]
total = total + minsPlayed[2,3]
total = total + minsPlayed[2,4]
print(total)
Refine the program to be more efficient. Write the refined version of the algorithm.
[4]
© OCR 2024. You may photocopy this page. 117 of 265 Created in ExamBuilder
B1 Chocolate bar £0.90
C1 Apple pieces £0.50
C2 Raisins £0.85
Users insert coins into the vending machine and then enter the two character item code of their selection. If the
user has inserted enough money, the vending machine will release the chosen item and output any change
required. If the user enters an invalid item code then a suitable error message is displayed.
[2]
(ii) Describe the difference between iterative testing and final testing.
[2]
(iii) Complete the following test plan for the vending machine.
© OCR 2024. You may photocopy this page. 118 of 265 Created in ExamBuilder
60 Jack is writing a program to add up some numbers. His first attempt at the program is shown.
a = input(“Enter a number”)
b = input(“Enter a number”)
c = input(“Enter a number”)
d = input(“Enter a number”)
e = input(“Enter a number”)
f = (a + b + c + d + e)
print(f)
Give two ways that the maintainability of this program could be improved.
[2]
© OCR 2024. You may photocopy this page. 119 of 265 Created in ExamBuilder
61(a) State what is meant by a syntax error and a logic error.
Syntax error
Logic error
[2]
© OCR 2024. You may photocopy this page. 120 of 265 Created in ExamBuilder
(b) This pseudocode algorithm totals all the numbers in the 0-indexed array scores
01 total = 0
04 next scoreCount
05 print(total)
Corrected line
Corrected line
[4]
62(a) Charlie is developing an adding game. The rules of the game are:
© OCR 2024. You may photocopy this page. 121 of 265 Created in ExamBuilder
• if the player gets the correct answer, 1 is added to their score
• at the end of the game their score is displayed.
Charlie has been told that the game will need to be tested before giving it to the players.
[2]
(ii) Complete the table by naming and describing one type of test that should be used on Charlie's program
before releasing it.
[2]
(iii) Complete the table by identifying and describing two features of an IDE that can be used when testing a
program.
Feature Description
[4]
© OCR 2024. You may photocopy this page. 122 of 265 Created in ExamBuilder
(b) Validating inputs can reduce errors when a program is being run.
Identify two methods of validation and explain how they can be used on this game.
Validation method 1
Use
Validation method 2
Use
[6]
A B Q
0 0 0
0 1 1
0
1
[4]
© OCR 2024. You may photocopy this page. 123 of 265 Created in ExamBuilder
64 A cinema uses the following criteria to decide if a customer is allowed to see a film that has a 15 rating:
Customers have to be 15 years of age or older to see the film. They also need to either have a ticket or
have the money to buy a ticket.
The table shows the inputs to the system that will output whether the customer can watch the film.
[2]
65
(i) Draw the logic diagram for the logic system P = A OR (B AND C)
© OCR 2024. You may photocopy this page. 124 of 265 Created in ExamBuilder
[3]
(ii) Complete the truth table for the logic system P = NOT (A OR B)
A B P
0 0 1
0 1
1 0
[4]
© OCR 2024. You may photocopy this page. 125 of 265 Created in ExamBuilder
66 A fast food restaurant offers half-price meals if the customer is a student or has a discount card. The offer is not
valid on Saturdays.
A computer system is used to identify whether the customer can have a half-price meal.
Input Value
A Is a student
B Has a discount card
C The current day is Saturday
The logic system P = (A OR B) AND NOT C is used.
(i) Complete the following logic diagram for P = (A OR B) AND NOT C by drawing one logic gate in each box.
[3]
© OCR 2024. You may photocopy this page. 126 of 265 Created in ExamBuilder
[2]
(iii) State how many rows (excluding any headings) would be required in a truth table for the logic expression:
P = (A OR B) AND NOT C
[1]
67(a) A garden floodlight system uses inputs from sensors and switches to decide whether it should be turned on.
The table shows the inputs into the system and the meaning of each input value:
The floodlight (Q) is designed to be on (Q = 1) when the switch is turned on and the motion sensor detects
motion at nighttime.
© OCR 2024. You may photocopy this page. 127 of 265 Created in ExamBuilder
[3]
(b) Identify the logic gates for truth table 1 and truth table 2.
© OCR 2024. You may photocopy this page. 128 of 265 Created in ExamBuilder
68(a) Harry is planning to create a computer game using a high-level programming language.
State why the computer needs to translate the code before it is executed.
[1]
(b) Harry can use either a compiler or an interpreter to translate the code.
Describe two differences between how a compiler and an interpreter would translate Harry's computer game.
[4]
© OCR 2024. You may photocopy this page. 129 of 265 Created in ExamBuilder
69 The area of a circle is calculated using the formula Π × r2, where Π is equal to 3.142 and r is the radius.
Finn has written a program to allow a user to enter the radius of a circle as a whole number, between 1 and 30,
and output the area of the circle.
Finn uses an IDE (Integrated Development Environment) to write his programs. Identify two features of an IDE
that Finn might use.
[2]
© OCR 2024. You may photocopy this page. 130 of 265 Created in ExamBuilder
70 The area of a circle is calculated using the formula π × r2 where π is equal to 3.142 and r is the radius.
A program is written to allow a user to enter the radius of a circle as a whole number between 1 and 30, then
calculate and output the area of the circle.
01 radius = 0
02 area = 0.0
03 radius = input("Enter radius")
04 if radius < 1 OR radius > 30 then
05 print("Sorry, that radius is invalid")
06 else
07 area = 3.142 * (radius ^ 2)
08 print (area)
09 endif
An Integrated Development Environment (IDE) is used to write the program.
Identify two features of an IDE that might be used when writing the program.
1
[2]
© OCR 2024. You may photocopy this page. 131 of 265 Created in ExamBuilder
71(a)
Tick (✓) one box in each row to identify whether the statement refers to a high-level language or a low-level
language.
[4]
(b) A translator is a common tool found in an Integrated Development Environment (IDE).
Describe two other common tools or facilities that an IDE can provide.
[4]
© OCR 2024. You may photocopy this page. 132 of 265 Created in ExamBuilder
72 Describe the advantages of writing a program in a high-level language instead of in assembly language.
[2]
© OCR 2024. You may photocopy this page. 133 of 265 Created in ExamBuilder
Mark Scheme
Total 4
Total 2
e.g.
total = 0
for x = 0 to 4
total = total + hoursPlayed[0,x]
next x
print (total)
© OCR 2024. You may photocopy this page. 134 of 265 Created in ExamBuilder
Mark Scheme
e.g.
e.g.
total = 0
for x = 0 to 29
for y = 0 to 4
Total = total + hoursPlayed[x,y]
next y
nextx
average = total / (30*5)
print (average)
Total 19
© OCR 2024. You may photocopy this page. 135 of 265 Created in ExamBuilder
Mark Scheme
4 a crim bait fright victor nym loose 4 1 mark for each row from row 2-5. Allow
e y ph multiple swaps in one stage, where it is
clear that a bubble sort has been applied.
bait crim fright victor nym loose
e y ph
bait crim fright nym victor loose
e ph y
bait crim fright nym loose victor
e ph y
bait crim fright loose nym victor
e ph y
e.g.
compare zebra to orange
compare to wind
compare to zebra
Total 8
© OCR 2024. You may photocopy this page. 136 of 265 Created in ExamBuilder
Mark Scheme
ii Taking firstname, surname and gender 6 1 mark for each correct bullet to a
as input maximum of 6.
Checking IF gender is male / female
(using appropriate selection) If used, a flowchart should represent the
For male …Generating last 3 letters of bulleted steps in the answer column
surname using appropriate string
manipulation
…Generating first 2 of letters of
firstname and adding to previous
For female…. correctly calculating as
before
Correct concatenation and output
Total 8
© OCR 2024. You may photocopy this page. 137 of 265 Created in ExamBuilder
Mark Scheme
6 i 1 mark per bullet to max 2 2 'Need the key to understand the data'
AO1 1a can get both MP2 and 3
Uses an algorithm to (1)
… jumble/scramble/mix up the data // AO2 1b Cannot read the data // data is
turns it into cypher text // by example (1) unreadable is NBOD
If it is accessed it cannot be
understood // it is unintelligible Examiner’s Comments
Use of keys to encrypt/decrypt data
This question was answered well by many
candidates who were able to identify that
encryption scrambles data and that a key
is required to read it.
© OCR 2024. You may photocopy this page. 138 of 265 Created in ExamBuilder
Mark Scheme
iii 1 mark for suitable output 1 Must logically work. Do not accept ""
e.g. AO3 2b around newMessage.
(1)
output(newMessage) // Parentheses not required.
print(newMessage)
Do not accept:
newMessage =
output(newMessage) or similar
Examiner’s Comments
Total 8
© OCR 2024. You may photocopy this page. 139 of 265 Created in ExamBuilder
Mark Scheme
7 a 1 mark per bullet to max 4, 1 mark per row 4 Correct Answer Only
AO2 1b
10 (4) Do not accept “X”, “Y”, etc.
6
6 Examiner’s Comments
2
This question required candidates to follow
through the given algorithm and decide on
the value that would be output given a set
of input values.
© OCR 2024. You may photocopy this page. 140 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 141 of 265 Created in ExamBuilder
Mark Scheme
place.
Exemplar 1
c 1 mark per bullet to max 4, 2 mark max per 4 Mark first method only in each section
method AO1 1b
(4) Examiner’s Comments
Compiler
…translates code in one go / all at This question was answered well by large
once numbers of candidates who were able to
…produces an executable file // does list the two translators listed in the
not need to be compiled again specification, compilers and interpreters.
Total 14
© OCR 2024. You may photocopy this page. 142 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 143 of 265 Created in ExamBuilder
Mark Scheme
Exemplar 2
AfL
© OCR 2024. You may photocopy this page. 144 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Total 4
© OCR 2024. You may photocopy this page. 145 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 146 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Total 6
© OCR 2024. You may photocopy this page. 147 of 265 Created in ExamBuilder
Mark Scheme
example algorithm
function ticketprice(numadult,
numchild)
price = (numadult * 19.99) +
(numchild * 8.99) + 2.50
return price
end function
Examiner’s Comments
© OCR 2024. You may photocopy this page. 148 of 265 Created in ExamBuilder
Mark Scheme
Misconception
Exemplar 3
Exemplar 4
© OCR 2024. You may photocopy this page. 149 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 150 of 265 Created in ExamBuilder
Mark Scheme
Misconception
d i 1 mark per bullet to max 2 2 The variable records whether a swap has
AO2 1b taken place; it does not perform the swap.
Flag / record whether a swap has (2)
taken place or not Examiner’s Comments
checked as condition to decide
whether to repeat This question presented candidates with
an algorithm for a bubble sort and asked
them to explain the purpose of the Boolean
value swaps.
© OCR 2024. You may photocopy this page. 151 of 265 Created in ExamBuilder
Mark Scheme
Misconception
Exemplar 5
© OCR 2024. You may photocopy this page. 152 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 153 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 154 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 155 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 156 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 157 of 265 Created in ExamBuilder
Mark Scheme
Exemplar 6
Total 28
© OCR 2024. You may photocopy this page. 158 of 265 Created in ExamBuilder
Mark Scheme
e.g.
compare to wind
compare to zebra
Total 8
© OCR 2024. You may photocopy this page. 159 of 265 Created in ExamBuilder
Mark Scheme
c 1 mark per bullet 4 Mark test data first, both must meet
(AO3 2c) different criteria. Then mark output for
Test data either 0 or less characters, or each.
20 or more characters
Stating correct output
Test data between 1 and 19 characters
(inc)
Stating correct output
© OCR 2024. You may photocopy this page. 160 of 265 Created in ExamBuilder
Mark Scheme
Output
Number of minutes
finalTotal = totalMins(hours,
minutes)
print (finalTotal)
function
totalMins(hours,minutes)
return total
endfunction
© OCR 2024. You may photocopy this page. 161 of 265 Created in ExamBuilder
Mark Scheme
iii Takes input from the user 4 High-level programming language / OCR
Compares if input is larger than 120… (AO3 2b) Exam Reference Language response
…if true, outputs "You played required
games for too long!"
…if false, outputs "You are under Do not accept pseudocode / natural
your time limit!" English.
Total 24
© OCR 2024. You may photocopy this page. 162 of 265 Created in ExamBuilder
Mark Scheme
C e.g.
A
D/F
F/D
Line 02 // empty = 0
Will reset empty to 0 on each iteration
of the loop
Line 07 // print (“empty”)
Will print out the string “empty” instead
of the value held in the variable
c i 1 mark per bullet, max 4 4 Do not accept generic answers that do not
refer to the data given.
Compare 5 (middle value) to 7
5 is smaller than 7 / 7 is larger than 7
so…
discard lower part of list / repeat with
upper part of list
…compare 7 to 7 (item found)
iii More efficient // Less time taken (to find 1 Accept reference to big O notation as
item) // fewer comparisons to make equivalent to more efficient.
(with large lists)
Total 16
© OCR 2024. You may photocopy this page. 163 of 265 Created in ExamBuilder
Mark Scheme
Total 3
© OCR 2024. You may photocopy this page. 164 of 265 Created in ExamBuilder
Mark Scheme
iii Ensures only certain users can access 2 Allow other examples of authentication for
the system BP2
Using password / other example of
authentication technique
b i 1 mark per bullet, max 4 5 BP2 and 3 must check for both ends of
range – must check that input data is not
Miles and age input separately negative.
Checks for valid mileage
Checks for valid age Allow FT for BP4 if already penalised
Checks both are greater than / greater under BP2 and/or 3 and output is
than equal to zero otherwise correct.
…correctly outputs both True and
False e.g.
© OCR 2024. You may photocopy this page. 165 of 265 Created in ExamBuilder
Mark Scheme
Total 19
© OCR 2024. You may photocopy this page. 166 of 265 Created in ExamBuilder
Mark Scheme
e.g.
price = input("enter price")
if price > 200 then
price = price – 40
elseif price > 100 then
price = price - 20
endif
print(price)
© OCR 2024. You may photocopy this page. 167 of 265 Created in ExamBuilder
Mark Scheme
alternative example
Total 14
© OCR 2024. You may photocopy this page. 168 of 265 Created in ExamBuilder
Mark Scheme
Total 3
Total 9
© OCR 2024. You may photocopy this page. 169 of 265 Created in ExamBuilder
Mark Scheme
ii Taking firstname, surname and teacher 6 1 mark for each correct bullet to a
or student as input (AO3 2b) maximum of 6.
Checking IF role is teacher/student
(using appropriate selection) If used, a flowchart should represent the
For teacher ...Generating last 3 letters bulleted steps in the answer column.
of surname using appropriate string
manipulation
...Generating first 2 of letters of
firstname and adding to previous
For student.... correctly calculating as
before
Correct concatenation and output
e.g.
Ask the user to input the data, store in
variables firstname, surname and role.
Check whether the role entered is teacher.
If it is, join the right 3 most letters in
surname with the left 2 letters in firstname.
Store this in username.
If it is not teacher, join the left 3 letters from
firstname with the left 2 letters from
surname. Store this in username. Output
the value in username.
Total 8
b Compiler translates all the code in one 4 1 mark to be awarded for the correct
go… (AO1 1b) identification and one for a valid description
…whereas an interpreter translates up to a maximum of 4 marks.
one line at a time No more than 2 marks for answers relating
Compiler creates an executable… only to interpreters and no more than 2
…whereas an interpreter does marks for answers only relating to
not/executes one line at a time compilers.
Compiler reports errors at the end…
…whereas an interpreter stops when it
finds an error
Total 5
© OCR 2024. You may photocopy this page. 170 of 265 Created in ExamBuilder
Mark Scheme
procedure storeData()
endif
F/endprocedure
procedure accessData()
endif
endif
endprocedure
Total 6
22 1 mark for each letter 4 Accept answers that write the definition
instead of the letter.
AO1
Decomposition D 1a(4)
Abstraction B
Input Sanitisation A
Casting F
Total 4
© OCR 2024. You may photocopy this page. 171 of 265 Created in ExamBuilder
Mark Scheme
Misconception
© OCR 2024. You may photocopy this page. 172 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Question (c) asked candidates to draw
flowchart and this was done particularly
well. Many candidates changed the given
pseudocode algorithm into a well-defined
process that covered the same steps as
the pseudocode.
© OCR 2024. You may photocopy this page. 173 of 265 Created in ExamBuilder
Mark Scheme
ii Comments 1
Use of constants
AO2
1b(1)
Total 10
© OCR 2024. You may photocopy this page. 174 of 265 Created in ExamBuilder
Mark Scheme
24 a 1 mark per bullet to max 6 4 Answer must refer to this array, not a
generic description of linear search.
Access “Rob” / studentnames[0]… AO2 “Access first item” is NE for BP1 or BP3.
…does not equal “Anna” // not desired 1b(4) Must refer to this scenario.
item // move on
Access “Anna” / studentnames[1] Max 1 for “Compare ‘Anna’ to each item in
…does equal “Anna” // stop // item list” if nothing else credited.
found
b Anna inserted before Rob as first two 5 Rob Anna Huw Emma Patrice Iqbal
elements…
Anna Rob Huw Emma Patrice Iqbal
…Huw correctly inserted into sorted AO2
list… 1b(5) Anna Huw Rob Emma Patrice Iqbal
…Emma correctly inserted into sorted Anna Emma Huw Rob Patrice Iqbal
list …
Anna Emma Huw Patrice Rob Iqbal
…Patrice correctly inserted into sorted
list … Anna Emma Huw Iqbal Patrice Rob
…Iqbal correctly inserted into sorted
list and no further changes made. Sorted list highlighted
Example algorithm
present=0
absent=0
for i = 0 to (studentnames.length) -1
print(studentnames[i])
attendance=input("absent or present?")
if attendance=="present" then
present=present+1
else
absent=absent+1
endif
© OCR 2024. You may photocopy this page. 175 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Question (c) asked candidates to write an
algorithm to:
AfL
© OCR 2024. You may photocopy this page. 176 of 265 Created in ExamBuilder
Mark Scheme
OCR support
Total 15
© OCR 2024. You may photocopy this page. 177 of 265 Created in ExamBuilder
Mark Scheme
b Pick middle value / pumpkin // find 4 Do not award generic responses except for
midpoint BP1 Must clearly show the steps taken for
Compare this to house, no match this list to achieve more than 1 mark.
pumpkin>house⋯
⋯so discard top half of list // focus on Do not award “splits the list in half” for BP1
bottom half or 4 – incorrect
Pick middle value again, either house
or flour⋯ Allow diagrams to demonstrate the process
⋯finds value // repeat to find value
Allow reasonable attempt at BP3 to allow
access to BP4
Examiner’s Comments
© OCR 2024. You may photocopy this page. 178 of 265 Created in ExamBuilder
Mark Scheme
AfL
Total 9
© OCR 2024. You may photocopy this page. 179 of 265 Created in ExamBuilder
Mark Scheme
Total 4
© OCR 2024. You may photocopy this page. 180 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 181 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Total 3
© OCR 2024. You may photocopy this page. 182 of 265 Created in ExamBuilder
Mark Scheme
Conditions Outcome
Not Saturday and Half price
(either a student or
has a discount
card).
Saturday or (not a Full price
student and doesn’t
have a discount
card). Question asks for a flowchart. Answers as
pseudocode, high level language or other
Saturday Student Discount Outcome forms are not acceptable 9 (NAQ).
Card
N N N Full price BP 4 and 5 only to be awarded if all
N N Y Half price decisions ensure correct output and clear
what the decisions are . FT for incorrect
N Y N Half price
shapes used or no inputs as long as
N Y Y Half price decisions are logically correct. Must
Y N N Full price attempt all three decisions.
Y N Y Full price
Allow calculation of half price / full price
Y Y N Full price instead of message but this must still be
Y Y Y Full price output.
© OCR 2024. You may photocopy this page. 183 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 184 of 265 Created in ExamBuilder
Mark Scheme
b Number of people (at the table) // 2 Ignore additional inputs that would be
whether there are more than 5 people (AO32a) sensible, such as cost of the meal.
or not
Choice between percentage and value Accept inputs in form of pseudocode / high-
// actual value of both percentage, level language.
value
Max 1 if other irrelevant inputs given.
Examiner’s Comments
Total 7
© OCR 2024. You may photocopy this page. 185 of 265 Created in ExamBuilder
Mark Scheme
29 a Merge into correct sorted lists of size 2 3 Do not credit BP3 simply for a sorted list.
(12 45 / -99 100 / –13 0 / –27 17) (AO2 1b)
Merge into correct sorted lists of size 4 Groups of numbers must clearly be the
(–99 12 45 100 / –27 –13 0 17)… correct size.
…Merge into correct sorted list of size
8 (–99 –27 –13 0 12 17 45 100) Do not all allow answers that show lists
being merged and then sorting in place,
this is incorrect.
Examiner’s Comments
Misconception
© OCR 2024. You may photocopy this page. 186 of 265 Created in ExamBuilder
Mark Scheme
b Any four bullet points for 1 mark each 4 Do not allow “split the list in half” on its own
(AO1 1b) as first step, this is incorrect.
Select / choose / pick middle number
(or left/right of middle as even number) Can get BP1 and 2 in one step (e.g. “check
and .. if the middle number is the one we’re
…check if selected number is equal to / looking for”)
matches target number (not just
compare) For BP3, accept focussing on correct half
…if searched number is larger, discard
left half // if searched number is Repeat (BP4) must be in the context of an
smaller, discard right half attempt at a binary search. Allow correct
Repeat until number found reference to recursion.
… or remaining list is of size 1 / 0
(number not found) “until number is not in the list” is NE for
final BP. Need to explain how this is
known.
Examiner’s Comments
© OCR 2024. You may photocopy this page. 187 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 188 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Total 9
© OCR 2024. You may photocopy this page. 189 of 265 Created in ExamBuilder
Mark Scheme
next x
print(total)
print(total / num)
Examiner’s Comments
© OCR 2024. You may photocopy this page. 190 of 265 Created in ExamBuilder
Mark Scheme
Total 6
© OCR 2024. You may photocopy this page. 191 of 265 Created in ExamBuilder
Mark Scheme
31 a i Checks that both firstname and 5 Must have some attempt at all three
surname are not empty… (AO3 2a) checks to give output mark(s). Check for
Checks that room is either “basic” or nights must check both upper and lower
“premium”… limits.
Checks that nights is between 1 and
5 (inclusive)… Iteration can be used as validation if input
…Outputs “NOT ALLOWED” (or repeatedly asked for until valid answer
equivalent) if any of the 3 checks are given.
invalid (must check all three)
…Outputs “ALLOWED” (or Do not accept logically incorrect Boolean
equivalent) only if all three checks are conditions such as if firstname or
valid (must check all three) surname == “”
Note : output marks are given for if entire Do not accept ≥ or ≤ for >=, <=. Ignore
system produces the correct output. For capitalisation
example, If a user enters a valid name and
room but an invalid number of nights, the e.g.
system should say “NOT ALLOWED” (or
equivalent). If this works and produces the valid = True
correct response no matter which input is if firstname == “” or surname
invalid, BP4 should be given. == “” then
valid = False
The same process holds for the valid end if
output - if (and only if) three valid inputs if room != “basic” and room !=
results in an output saying “ALLOWED” (or "premium" then
equivalent), BP5 should be given. Do not valid = False
give this if ALLOWED is printed when (for endif
example) two inputs are valid and one is if nights < 1 or nights > 5
invalid. then
valid = False endif
For any output marks to be given, a if valid then
sensible attempt must have been made at print(“ALLOWED”)
all three checks. These may not be else
completely correct (and may have been print(“NOT ALLOWED”)
penalised in BPs 1 to 3) but should be endif
enough to allow the FT marks for output.
BP1 to 3 can check for valid or invalid
inputs. . Pay particular attention to use of
AND / OR. Only give marks for output if
these work together correctly.
© OCR 2024. You may photocopy this page. 192 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
IF room == “basic” or
“premium” is incorrect as the
second part of the statement is not
evaluated against anything. This was
perhaps the most common mistake.
IF room == “basic” or room ==
“premium” is correct and checks for
validity.
IF room == basic or room ==
© OCR 2024. You may photocopy this page. 193 of 265 Created in ExamBuilder
Mark Scheme
Exemplar 3
© OCR 2024. You may photocopy this page. 194 of 265 Created in ExamBuilder
Mark Scheme
b i Function header for newPrice… 4 BP1 must be clear that a new function is
…taking (at least) two parameters (AO3 2b) being defined. E.g. function / def
…correctly calculates price based on keyword. Allow FT for subsequent marks if
parameters (if present) within function not present.
…/
… returns this calculated price Ignore any code outside attempt at function
definition.
e.g.
© OCR 2024. You may photocopy this page. 195 of 265 Created in ExamBuilder
Mark Scheme
function newPrice(nights,
room)
price = 80 * nights
endif
return price
endfunction
Examiner’s Comments
© OCR 2024. You may photocopy this page. 196 of 265 Created in ExamBuilder
Mark Scheme
e.g.
print(newPrice(“premium”, 5))
x = newPrice(5, “premium”)
print(x)
Examiner’s Comments
© OCR 2024. You may photocopy this page. 197 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
d Inputs hours AND electric (two 6 Initialisation of price and hours not
separate inputs), storing or using (AO3 2c) necessary, but if present hours must be
these. non-zero for BP6 to be given.
Checks if car is electric (IF/Select
statement)… BP5 must include all points attempted. Can
… correctly calculates and outputs still be credited if any of BP1 to 4 not
price (hours * 2 // price / 2) for electric attempted / incorrect.
… correctly calculates and outputs
price (hours * 4 // electric price * 2) for BP6 can be given as FT even if BP5 (loop)
non-electric is in the wrong place / does not include all
Attempt at repetition of BP1 to 4… required code
…until 0 hours entered
BP6 could be achieved as repeated
function calls / recursion
© OCR 2024. You may photocopy this page. 198 of 265 Created in ExamBuilder
Mark Scheme
e.g.
while hours != 0
hours = input(”Enter hours”)
electric = input(“enter Y for
electric or N”)
if electric == ”Y” then
price = hours * 2
elseif electric == ”N” then
price = hours * 4
endif
print(price)
endwhile
Examiner’s Comments
© OCR 2024. You may photocopy this page. 199 of 265 Created in ExamBuilder
Mark Scheme
Total 23
© OCR 2024. You may photocopy this page. 200 of 265 Created in ExamBuilder
Mark Scheme
32 a 1 mark per row 4 No mark if more than 1 tick for that row.
(AO1 1b)
Allow other indications of choice (e.g.
Statement Low- High- cross) as long as clear.
level level
Examiner’s Comments
The same language can ✓
be used on computers
This question was answered well by many
that use different
candidates. The strongest responses
hardware
showed a good understanding of the
It allows the user to ✓ difference between low-level and high-level
directly manipulate languages. Incorrect responses tended to
memory be on the first row related to portability. A
It allows the user to ✓ high-level language such as Python is
write English-like words portable, with translators available for
many different types of processors. A low-
It always needs to be ✓
level language is specific to one type of
translated into object
processor.
code or machine code
e.g.
total = sum(num1, num2)
x = num1 + num2
total = x
Examiner’s Comments
© OCR 2024. You may photocopy this page. 201 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 202 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Total 11
© OCR 2024. You may photocopy this page. 203 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 204 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 205 of 265 Created in ExamBuilder
Mark Scheme
c i 1 mark each for insertion and bubble sort, 2 Answer must reference both bubble sort
max 2 (AO1 1b) and insertion sort for 2 marks except if
efficiency mark plus expansion given.
Insertion sort:
Allow reference to big O for efficiency
inserts/moves values into correct discussion.
position
inserts value once (then in correct Only award efficiency once. Only award
position) fewer iterations once
stops when end of array reached //
completes in one pass through the Do not accept “completes in one iteration”
array for insertion sort.
moves items down the array / left
start of array becomes sorted first Accept list / data / values / etc for array.
creates a sorted array within an array //
has a sorted/unsorted partition / “when data more scrambled” only makes
section / list sense when discussing efficiency/speed,
starts on 2nd value do not give marks for saying that either can
more efficient/faster than bubble sort handle data that is more scrambled (they
… because fewer iterations / both can sort data however it is arranged).
comparisons (on average)
… when data more scrambled Do not accept “bubble/insertion sort does
not” for 2nd mark.
Bubble sort :
Examiner’s Comments
compares/swaps pairs of values
value is repeatedly moved/swapped Question 3(c)(i) and Question 3(c)(ii) asked
(until in correct position) candidates to describe one difference and
repeats if a swap has been made // two similarities between an insertion sort
needs multiple passes and a bubble sort.
will complete a final iteration once
sorted (to check for no swaps needed) Examiners were instructed to be generous
moves items up the array in their interpretation of the requirements of
end of array becomes sorted first both algorithms. This included considering
moves/bubbles the highest value to the both their algorithmic implementation and
top the understanding of how these are
less efficient/slower than insertion sort typically described on a classroom
(on large sets of values) whiteboard.
… more iterations / comparisons (on
average) As such, many combinations of answers
… when data more scrambled could gain the marks available.
© OCR 2024. You may photocopy this page. 206 of 265 Created in ExamBuilder
Mark Scheme
Both produce a sorted list / array “Allows sorting of numbers and strings”
Both work in place / without duplicating meets BP1
data / without using divide and conquer
Both need a temporary variable Allow answers relating to not needing
Both swap values additional memory as BP2.
Both use loops / iteration / repeats
Both loops are nested / inside each Allow “breaking into smaller lists” as divide
other and conquer for BP2.
Both (may) need multiple passes
Both use selection If answer is a statement (e.g. “uses loops”),
Both work with an array / list data assume candidate is talking about both
structure algorithms doing this.
Both work from left to right
Both build up sorted list one item at a Examiner’s Comments
time (after every pass)
Both compare (pairs of) values Question 3(c)(i) and Question 3(c)(ii) asked
Both (typically) less efficient / slower candidates to describe one difference and
than merge sort (or other sorting two similarities between an insertion sort
algorithms) and a bubble sort.
Both inefficient / slow for larger /
unsorted lists // efficient for small / Examiners were instructed to be generous
(nearly) sorted lists in their interpretation of the requirements of
Both start by comparing first two values both algorithms. This included considering
both their algorithmic implementation and
the understanding of how these are
typically described on a classroom
whiteboard.
Total 8
© OCR 2024. You may photocopy this page. 207 of 265 Created in ExamBuilder
Mark Scheme
Example answer
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
end if
next count
print("You scored " + score)
Examiner’s Comments
© OCR 2024. You may photocopy this page. 208 of 265 Created in ExamBuilder
Mark Scheme
Total 6
Total 4
© OCR 2024. You may photocopy this page. 209 of 265 Created in ExamBuilder
Mark Scheme
36 a radius 2
area
Total 4
© OCR 2024. You may photocopy this page. 210 of 265 Created in ExamBuilder
Mark Scheme
37 1 mark per bullet, mark in pairs. Max 2 per 4 Mark first answer only in each section
point. AO2 1a
(2) For validation, allow one example of a type
e.g. AO2 1b of validation (e.g. type check, range check)
(2)
Input sanitisation e.g. question so allow other sensible
…cleaning up input data / removing examples such as audit logging, encryption
unwanted data of data
…by example (e.g. removing special
characters / preventing SQL injection) Do not allow “data is correct” as expansion
for validation – validation checks that data
Validation is sensible or follows rules, NOT that it is
…checking whether input data should correct.
be allowed / is sensible / follows criteria
…by example (e.g. goals cannot be Planning for contingencies and anticipating
less than 0) misuse are not examples by themselves,
but discussion of these may fit under other
Verification points – e.g. input sanitisation, validation.
… checking whether data has been
entered correctly Examiner’s Comments
…by example (e.g. double entry /
visual check) This question asked candidates to describe
two examples of defensive design that
Authentication should be considered when developing the
…ensuring only allowed / authorised program for OCR FC.
users can gain access
…by example (e.g. usernames It was clear that large numbers of
/passwords) candidates did not understand the term
‘defensive design’ and gave wide ranging
Maintainable code answers that linked topics as wide as
…to allow other programmers to decomposition to defensive tactics in
understand the code football.
…by example(e.g. comments,
indentation, meaningful variable Where this topic was understood, the most
names) common answers given were those listed
in the specification of input sanitisation,
validation and authentication.
Misconception
© OCR 2024. You may photocopy this page. 211 of 265 Created in ExamBuilder
Mark Scheme
Total 4
Total 1
© OCR 2024. You may photocopy this page. 212 of 265 Created in ExamBuilder
Mark Scheme
E.g
Comments/annotation…
…E.g. any relevant example, such as
line 4 checks the input is valid
Indentation…
…E.g. indenting within IF statement
Using constants…
…E.g. π
Total 11
© OCR 2024. You may photocopy this page. 213 of 265 Created in ExamBuilder
Mark Scheme
Real (1)…
Total 3
Total 2
© OCR 2024. You may photocopy this page. 214 of 265 Created in ExamBuilder
Mark Scheme
42 a One mark per correct choice 3 Accept other markings that indicate a
choice has been made (e.g. a cross, etc)
SELECT ItemCode, ItemName
FROM tblStock
WHERE Price >=60
© OCR 2024. You may photocopy this page. 215 of 265 Created in ExamBuilder
Mark Scheme
iii asks for price and discount code to be 6 High-level programming language / OCR
input Exam Reference Language response
…passes both to the checkdiscount() required
function as parameters…
...stores / uses returned value Do not accept pseudocode / natural
calculates total of all prices language.
entered/returned
repeats until 0 is entered as price BP3 allow total of prices entered as FT if
outputs calculated total candidate does not achieve BP2
e.g.
total = 0
do
price = input("Enter a
price")
code = input("Enter a
discount code")
newprice =
checkdiscount(price, code)
total = total + newprice
until price == 0
print(total)
alternative example
total = 0
price = 1
while price != 0
price = input("Enter a
price")
code = input("Enter a
discount code")
total = total +
checkdiscount(price, code)
endwhile
print(total)
Total 16
Total 3
© OCR 2024. You may photocopy this page. 216 of 265 Created in ExamBuilder
Mark Scheme
AO2
1b(1)
Total 2
Misconception
Total 4
© OCR 2024. You may photocopy this page. 217 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Question (e) covered SQL. It was clear that
many candidates were not sure what was
being asked for in this question. Many
incorrectly attempted to use keywords such
as IF and THEN. The use of SQL in this
specification is limited to a small number of
keywords, as listed in the specification.
OCR support
e.g.
newstate = input("Enter the new state : ")
statevalue = 1
© OCR 2024. You may photocopy this page. 218 of 265 Created in ExamBuilder
Mark Scheme
statevalue = 2
statevalue = 3
else
print("Invalid state")
endif
Examiner’s Comments
Question (f) asked candidate to rewrite an
algorithm that used switch/case to
perform the same actions but using IF
statements. It was clear that many
candidates did not understand the use of
switch/case. Some languages (such as
Python) do not include support for these. It
is important that these constructs are still
taught.
OCR support
Total 9
© OCR 2024. You may photocopy this page. 219 of 265 Created in ExamBuilder
Mark Scheme
47 i 3 1 CAO
AO1
1b(1)
ii 1 1 CAO
AO1
1b(1)
Total 2
Total 6
© OCR 2024. You may photocopy this page. 220 of 265 Created in ExamBuilder
Mark Scheme
Misconception
b i Number with a decimal / fractional part 2 One mark for definition, one mark for
Suitable example (e.g. 17.24) example
Do not accept float as definition
Allow fractions as example
ii Whole number // number with no 2 One mark for definition, one mark for
decimal / fractional part example
Suitable example (e.g. 17)
© OCR 2024. You may photocopy this page. 221 of 265 Created in ExamBuilder
Mark Scheme
c i Count = 0 5
Output Count
All non-decision boxes and YES from
decision boxes linked in a sequential
fashion from Start to End.
NO from first decision box linked to
skip over increment of count
NO from second decision box linked
back to INPUT
Examiner’s Comments
© OCR 2024. You may photocopy this page. 222 of 265 Created in ExamBuilder
Mark Scheme
AfL
Examiner’s Comments
This question utilised similar understanding
to this part, but utilised the loop in a
different way.
© OCR 2024. You may photocopy this page. 223 of 265 Created in ExamBuilder
Mark Scheme
AfL
Total 20
© OCR 2024. You may photocopy this page. 224 of 265 Created in ExamBuilder
Mark Scheme
b i 16 1
ii 2 1
iii 9 1
© OCR 2024. You may photocopy this page. 225 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
This question was asked candidates to use
string manipulation to output specific words
or sentences from given values. The mark
scheme given shows answers using
substring() which is the method given
in the specification pseudocode guide.
Misconception
Total 7
© OCR 2024. You may photocopy this page. 226 of 265 Created in ExamBuilder
Mark Scheme
51 a Function call Returned value 3 Do not accept “blank” or any other returned
value for third call.
checkblock(2,1) B
checkblock(3,0) A Ignore case and spelling as long as
checkblock(2,3) FREE recognisable.
c i Parameter values outside index range / 1 Answer must refer to either array or
larger than 4 / smaller than 0 // -1, 16 is gameboard / grid / block
not a valid block
Total 14
© OCR 2024. You may photocopy this page. 227 of 265 Created in ExamBuilder
Mark Scheme
OCR Reference Selecti Iteratio Accept any response (ticks, crosses, etc)
Language code on n that clearly indicates candidate’s choice.
for i = 1 to 10 ✓
print(i)
Examiner’s Comments
next i
whilescore != 0 ✓
Candidates appeared to struggle with this
playgame() question. In particular the use of
switch/case was not well understood. This
endwhile may be because some high-level
if playerHit() ✓ languages such as Python have not
then traditionally supported this. The recent
update to Python 3.10 introduces this
score = 0 construct. Centres who use Python may
want to consider upgrading their
endif installation to allow practical
implementation of the switch/case
switch bonus: ✓
construct.
case 0:
score = 9
case 1:
score = 7
case 2:
score = 5
endswitch
Total 4
© OCR 2024. You may photocopy this page. 228 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 229 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Total 6
© OCR 2024. You may photocopy this page. 230 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Total 7
© OCR 2024. You may photocopy this page. 231 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 232 of 265 Created in ExamBuilder
Mark Scheme
iii SELECT FirstName, Surname, 4 Order of fields for BP1 not important but
Nights, Room, StayComplete // (AO3 1) must show all fields and be separated by
SELECT* (AO3 2c) commas.
FROM TblBookings
WHERE Ignore capitalisation and spacing. Spelling
Nights > 1 // Nights >= 2 // must be correct. Ignore quotes around
Nights BETWEEN 2 AND 5. numeric values or field/table names.
Examiner’s Comments
Total 7
© OCR 2024. You may photocopy this page. 233 of 265 Created in ExamBuilder
Mark Scheme
Example answer 1
if SystemArmed then
if DoorSensorActive then
SoundAlarm()
© OCR 2024. You may photocopy this page. 234 of 265 Created in ExamBuilder
Mark Scheme
Example answer 2
Example answer 3
if SystemArmed and
(DoorSensorArmed or
WindowSensor) then
SoundAlarm()
endif
if SystemArmed and
DoorSensorArmed or WindowSensor
then
Example answer 4
if SystemArmed and
DoorSensorArmed
SoundAlarm()
else if SystemArmed and
WindowSensorArmed
SoundAlarm()
endif
Examiner’s Comments
© OCR 2024. You may photocopy this page. 235 of 265 Created in ExamBuilder
Mark Scheme
Misconception
if SystemArmed AND
DoorSensorActive OR
WindowSensorActive then
SoundAlarm()
© OCR 2024. You may photocopy this page. 236 of 265 Created in ExamBuilder
Mark Scheme
Exemplar 1
c i 1 mark for 1
(AO3 1) Examiner’s Comments
Line 04
Concatenation is the process of joining
strings together. In OCR Exam Reference
Language, this is done using the + symbol.
Line 04 joins together sensorType and
sensorNumber, assigning the
concatenated result to the variable
sensorID.
© OCR 2024. You may photocopy this page. 237 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 238 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Misconception
if x == True then…
if x then…
© OCR 2024. You may photocopy this page. 239 of 265 Created in ExamBuilder
Mark Scheme
iv 1 mark from 1
(AO3 1) Examiner’s Comments
Line 01
Line 02 The program code given contains two
Line 03 explicit calls to functions. There is one
Line 05 function call on line 02 for
CheckSensorCode() and one function
call on line 05 for ResetSensor().
However, many programming languages
(including Python) implement input as a
function and so examiners were instructed
to also give credit where candidates
identified lines 01 or 03.
© OCR 2024. You may photocopy this page. 240 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 241 of 265 Created in ExamBuilder
Mark Scheme
Example answer
procedure SaveLogs(data,
filename)
logFile = open(filename)
logFile.writeLine(data)
logFile.close()
endprocedure
Examiner’s Comments
© OCR 2024. You may photocopy this page. 242 of 265 Created in ExamBuilder
Mark Scheme
Exemplar 2
Examiner’s Comments
© OCR 2024. You may photocopy this page. 243 of 265 Created in ExamBuilder
Mark Scheme
Example answer 1
total = 0
date = input("Please enter
date")
for count = 0 to
events.length-1
if events[0, count] == date
then
total = total +
events[3,count]
endif
next count
print("There were " + total + "
events on " + date)
Example answer 2
total = 0
date = input("Please enter
date")
for item in events:
© OCR 2024. You may photocopy this page. 244 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Exemplar 3
© OCR 2024. You may photocopy this page. 245 of 265 Created in ExamBuilder
Mark Scheme
Total 30
Total 6
© OCR 2024. You may photocopy this page. 246 of 265 Created in ExamBuilder
Mark Scheme
58 Initialises total as 0 and prints out total 4 High-level programming language / OCR
the end (as per original program) (AO3 2c) Exam Reference Language response
Uses iteration, e.g. FOR, WHILE required
…that repeats 5 times
…correctly adds up values using loop Do not accept pseudocode / natural
index English.
e.g.
total = 0;
for (int x = 0; x <= 4; x++){
total = total +
hoursplayed[2][x];
}
System.out.println (total);
Total 4
© OCR 2024. You may photocopy this page. 247 of 265 Created in ExamBuilder
Mark Scheme
59 i 1 mark per bullet to max 2 e.g. 2 Allow two any suitable examples for two
marks
Check the program meets the user AO1
requirements 1b(2) BOD “find errors”, “find bugs” for BP2
Check the program works (as
intended) // detect logic / syntax errors “fix errors” by itself is one mark (BP4)
Check the program does not crash
(under invalid entry) // check error
messages are suitable
…allow these errors to be fixed
…make sure there are no problems
when released
Any suitable example related to the
vending machine e.g. gives correct
change
ii 1 mark per bullet to max 2 2 Do not accept just “repeatedly testing” for
iterative
Iterative is during development // AO1
repeatedly testing after/while making 1b(2) BOD “iterative testing tests
changes modules/sections”
Final is when the development is
(almost) complete // done after iterative
testing
iii Code Money Expected result 3 For £0.49 accept any value <£0.50. Must
entered inserted be a specific value, not a description.
AO3
2b(3) Accept any suitable error message for
invalid selection
C2
£0.49
(or any
value less
that £0.50)
Invalid
Selection
(or any suitable
error message)
Total 7
© OCR 2024. You may photocopy this page. 248 of 265 Created in ExamBuilder
Mark Scheme
60 Any two bullet points for one mark each: 2 Do not accept indentation (no code to
(AO2 1b) sensibly indent in this example)
Add comments
Name variables sensibly “Use a subroutine” is not enough. Must be
Put into subroutine / procedure / clear that existing code will be put into a
function new subroutine.
Use loop / iteration
Examiner’s Comments
Total 2
© OCR 2024. You may photocopy this page. 249 of 265 Created in ExamBuilder
Mark Scheme
© OCR 2024. You may photocopy this page. 250 of 265 Created in ExamBuilder
Mark Scheme
scores[scoreCount]
total += scores[scoreCount] Allow description of change that would be
made (e.g. “change 1 to 0”)
Examiner’s Comments
Total 6
© OCR 2024. You may photocopy this page. 251 of 265 Created in ExamBuilder
Mark Scheme
ii 1 mark for name, 1 mark for matching 2 Allow other sensible descriptive names for
description (1 AO1 testing.
1a)
e.g. (1 AO2 Description must match test type.
1b)
Final / terminal testing… Must be a description and not just an
… Completed at the end of example, but example may support
development / before release. description.
… to test the product as a whole.
Do not accept descriptions that simply
Iterative / incremental testing… repeat type of test without further
…completed during development. clarification (e.g. “boundary, testing the
…after each module is completed. boundary”).
… test module in isolation
Allow :
Normal testing…
…test using data that should be Black box testing…
accepted // …testing without access / knowledge
…test that is expected to work / pass of a system’s workings.
© OCR 2024. You may photocopy this page. 252 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
© OCR 2024. You may photocopy this page. 253 of 265 Created in ExamBuilder
Mark Scheme
iii 1 mark for feature 4 Allow other sensible names for features.
1 mark for matching description (AO2 1b)
e.g. Description must add more than is given in
the identification of the feature to be
Translator / compiler / interpreter … awarded. For example, “keyword
… convert to low-level/machine code highlighting, highlights keywords” is 1 mark
…allow program to be executed / run for the feature only.
…produce executable file (only for
compiler) If compiler and interpreter given as two
…stops execution when error found distinct features, allow both (with suitable
(interpreter only) descriptions). Do not allow translator and
compiler/interpreter.
Run-time environment / output
window… Description must match feature.
…allows program / code to be run /
executed “finding errors” is NE for description of
…shows output of the program / code error reporting.
© OCR 2024. You may photocopy this page. 254 of 265 Created in ExamBuilder
Mark Scheme
b 1 mark for method, 1 mark to max 2 for 6 Validation must be applied to the rules of
each use (4 AO2 the game as given; do not accept uses
1b) related to input not asked for (e.g. names,
e.g. (2 AO1 passwords, etc).
1a)
Range check Do not accept uses that simply repeat the
… checks upper/max / lower/min / name of the check (e.g. “range check,
boundaries checks a range of numbers”)
… make sure the players answer /
input is between sensible limits (e.g. 20 For range check, values must be sensible
or less, between 2 and 20 inclusive) // (e.g. 1 to 50), and allow input of 2 to 20. Do
not negative not allow 1 / 10 (answer could be over
…by example of program code this).
© OCR 2024. You may photocopy this page. 255 of 265 Created in ExamBuilder
Mark Scheme
… making sure the data inputted is one The stronger responses stated a validation
from an allowed set of values method and linked the use of the validation
… checking that answer / input is one method to the game. For example, a
of [2, 3…20] inclusive requirement of the game is that two
…by example of program code random numbers between 1 and 10 are
picked. It is sensible to suggest that
validation ensuring the total is between 2
and 20 could be implemented. Further
discussion relating to how this could be
done, even as far as suggesting sensible
high-level code that could be used would
have developed the response.
Misconception
Total 14
© OCR 2024. You may photocopy this page. 256 of 265 Created in ExamBuilder
Mark Scheme
Total 4
Total 2
© OCR 2024. You may photocopy this page. 257 of 265 Created in ExamBuilder
Mark Scheme
B AND C AO1
OR gate with two inputs, one of which 1b(3)
is A
…correct connection of these two
gates with no additional gates /
connections
Total 7
© OCR 2024. You may photocopy this page. 258 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
ii To show all possible inputs (to the logic 2 For 2nd BP, must be clear that the output is
circuit)… (AO1 1b) linked to the input values given.
…and the associated/dependent output
(for each input) “All possible combinations of inputs and
outputs” gains the first mark (all possible
inputs) but not the second.
© OCR 2024. You may photocopy this page. 259 of 265 Created in ExamBuilder
Mark Scheme
Examiner’s Comments
Misconception
Exemplar 1
Total 6
© OCR 2024. You may photocopy this page. 260 of 265 Created in ExamBuilder
Mark Scheme
67 a 1 mark each, max 2 if not fully correct 3 Shapes of logic gates must be correct.
circuit. (AO3 2a) NOT gate must include circle for inversion.
No other gates should include circle.
NOT B
AND gate with A / C as one direct AND gates must have two different inputs,
input… NOT gate must have one input. All gates
…Second AND gate with other must have one output.
(unused) A / C as direct input and
output of previous stage as other input Correct system will always have NOT B
and two other AND gates correctly joined.
Fully correct circuit is any of :
Accept alternative systems that produce
Q = (A AND NOT B) AND C the correct output.
Q = A AND (NOT B AND C)
Q = (A AND C) AND NOT B Accept (BOD) three input AND gate for
BP2 and BP3 if used correctly.
See examples below :
OK if inputs/outputs not joined up to
A/B/C/Q as long as intention clear.
Examiner’s Comments
© OCR 2024. You may photocopy this page. 261 of 265 Created in ExamBuilder
Mark Scheme
Total 5
b Compiler translates all the code in one 4 1 mark to be awarded for the correct
go… identification and one for a valid description
… whereas an interpreter translates up to a maximum of 4 marks. No more
one line at a time than 2 marks for answers relating only to
Compiler creates an executable… interpreters and no more than 2 marks for
…whereas an interpreter does not / answers only relating to compilers.
executes one line at a time
Compiler reports all errors at the end…
… whereas an interpreter stops when it
finds an error
Total 5
Total 2
© OCR 2024. You may photocopy this page. 262 of 265 Created in ExamBuilder
Mark Scheme
Total 2
© OCR 2024. You may photocopy this page. 263 of 265 Created in ExamBuilder
Mark Scheme
b 1 mark per bullet, max 4 4 Allow other tools available in an IDE with
suitable expansion (e.g. breakpoints, watch
e.g. window, stepping, pretty printing, etc)
Editor
…to enable program code to be
entered / edited
Error diagnostics / debugger
…to display information about errors /
location of errors / suggest solutions
Run-time environment
…to enable program to be run / to
check for runtime errors / test the
program
Total 8
© OCR 2024. You may photocopy this page. 264 of 265 Created in ExamBuilder
Mark Scheme
Total 2
© OCR 2024. You may photocopy this page. 265 of 265 Created in ExamBuilder