0% found this document useful (0 votes)
4 views

Paper 2 Revision Booklet 2

Uploaded by

lucigutmar2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Paper 2 Revision Booklet 2

Uploaded by

lucigutmar2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 265

1 There is a subroutine, HEX(), that takes a denary number between 10 and 15 and returns the corresponding

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.

Fig. 2 shows part of the array, with 4 students.

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])

The output is 20.

(i) Write the code to output the number of minutes student 0 played computer games on Wednesday.

[1]

(ii) State the output if Heath runs the code:

print (hoursPlayed[2,1])

© OCR 2024. You may photocopy this page. 2 of 265 Created in ExamBuilder
[1]

(iii) State the output if Heath runs the code:

print (hoursPlayed[3,1] + hoursPlayed[3,2])

[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.

(i) Explain how encryption helps to protect Hamish’s documents.

[2]

(ii) One encryption method is a Caesar cipher.

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.

For example, if the message read: HELLO

This would be stored as: IFMMP

The following pseudocode algorithm takes a string of uppercase letters as input and uses the Caesar cipher
to encrypt them.

The functions used in the algorithm are described in the table:

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)

Complete the pseudocode algorithm to perform a Caesar cipher.


01 message = input("Please enter your string")
02 newMessage = " "
03 messageLength = message.length
04 for count = 0 to ............................................
05 ASCIIValue = ASC(message.subString(................,1))
06 ASCIIValue = ASCIIValue + ................................
07 if ASCIIValue >90 then
08 ASCIIValue = ................................ – 26
09 endif
10 newMessage = ................................ + CHR(ASCIIValue)
11 next count
[5]

(iii) The algorithm needs adapting. An extra line (line 12) is needed to output the encrypted message.

Write line 12 to output the encrypted message in pseudocode or programming code.

[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.

01 num = input(“enter a number”)


02 if num MOD 2 >= 0 then
03 print(“even”)
04 else
05 pritn(“odd”)
06 endif
The program contains a logic error on line 02.

(i) State what is meant by a logic error.

[1]

(ii) Give a corrected version of line 02 that fixes the logic error.

[1]

(b) The program contains a syntax error on line 05.

(i) State what is meant by a syntax error.

[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.

(i) Define what is meant by abstraction.

[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]

Elliott wants to count how many matches end with 0 goals.

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.

(i) Use pseudocode to create an algorithm for the function ticketprice().

© 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.

Data type of returned value Tick (✓) one box


Integer
Real
Boolean
String

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]

(c) A list of valid discount codes is shown below.

[NIC12B, LOR11S, STU12M, VIC08E, KEI99M, WES56O, DAN34S]

(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]

(ii) Explain the purpose of lines 06 to 08 in this bubble sort algorithm.

© 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.

Create an algorithm that:

• asks the user to input the height of the rider, in centimetres


• if needed, asks if they are riding with an adult
• outputs whether or not they are allowed to ride
• repeats this process until 8 people have been allowed to ride.

© 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.

A sample of this data is shown in Fig. 3.

crime bait fright victory nibble loose


Fig. 3

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.

amber house kick moose orange range tent wind zebra


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.

You must use either:

• OCR Exam Reference Language, or


• a high-level programming language that you have studied.

mins = input("Enter minutes played: ")

if mins < 0 ..................... mins ..................... then

..................... ("Invalid input")

endif [3]

(ii) Complete the following test plan for the program in (i).

Test data Test type Expected result


25 Normal Value accepted
Invalid Invalid input
message displayed
Boundary
[3]

© 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)

Complete the trace table to test this program.

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").

variable.length returns the number of characters in variable.


variable.upper returns the characters in variable in upper case.

valid = false

while(valid == false)

gameName = input("Enter the game name")

if (gameName.length > 0) AND (gameName.length < 20)

gamesPlayed = gameName.upper

valid = true

print("Valid game name")

else

print("Game name is not valid")

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.

The teacher wants to create a sub program to perform the calculation.

The program has been started but is not complete.

Complete the design for the program.

hours = input("Please enter number of hours played")


minutes = input("Please enter number of minutes played")
finalTotal = .................................................................................
print(finalTotal)
function ................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
endfunction
[4]

(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.

Rewrite the flowchart as a program.


You must use either:
• OCR Exam Reference Language, or
• a high-level programming language that you have studied.

[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.

An example for one student is shown:

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")

(i) The algorithm contains logic errors.

Define the term logic error.

[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.

(i) The grades for one student are shown:

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.

Your answer must refer to the grades provided.

[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]

(iii) Give one advantage of a binary search over a linear search.

[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.

Input Criteria (True / False)


A The customer is 15 or over
B The customer has a ticket
C The customer has the money to buy a ticket
Complete the following algorithm to output whether the customer is allowed to see the film or not.

A = input("Is the customer 15 or over?")


B = input("Does the customer have a ticket?")
C = input("Does the customer have money to buy a ticket?")

[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.

(i) Define the term abstraction.

[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.

(i) Write an algorithm that will:

• 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.

Identify suitable test data for each type of test.

Miles Age

Normal

Erroneous

Boundary

[3]

(iii) Identify when iterative testing is performed.

[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%.

Write an algorithm that:

• asks the user for the current battery charge percentage


• outputs "full" for a battery currently at 100%
• calculates how long this battery would take to charge
• outputs this in hours and minutes.

© 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.

Price input Test type Expected price output


50 Normal

100 Boundary

150 Normal

200 Boundary

250 Normal

© OCR 2024. You may photocopy this page. 40 of 265 Created in ExamBuilder
[3]

(ii) Rewrite the algorithm above.

You must use either:

• OCR Exam Reference Language, or


• A high-level programming language that you have studied

[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.

stocklevel = input("Enter stock level")


if stocklevel >= 5 or =< 25 then
print(Not in demand)
else
print(In demand)
endif

The program contains syntax and logic errors.

Refine the program to correct the errors and write the refined version of the program.

You must use either:

• OCR Exam Reference Language, or


• A high-level programming language that you have studied

[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).

P = NOT(A AND B) Tick (✓) one box

[1]

© OCR 2024. You may photocopy this page. 44 of 265 Created in ExamBuilder
18(a) A program needs to perform the following tasks:

• Input two numbers from the user


• Compare both numbers and output the largest number.

Complete the pseudocode for this program.

num1 = input("enter first number")

num2 = input("enter second number")

.................. num1 > .................. then

.....................................

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:

• Input a number from the user


• Double the number input and print the result
• Repeat bullets 1 and 2 until the user enters a number less than 0.

Write an algorithm for this program.

[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]

(b) The program design is updated to create usernames as follows:

• 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]

(b) Either a compiler or an interpreter can translate the code.

Describe two differences between how a compiler and an interpreter would translate the code.

[4]

21 Ali’s tablet computer has an operating system.

Ali’s computer uses virtual memory. Ali has written two procedures to help himself understand how virtual
memory works.

storeData() describes how data is stored in RAM.


accessData() describes how data is read from RAM.

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()

if RAM is ......................... then

© OCR 2024. You may photocopy this page. 49 of 265 Created in ExamBuilder
move data from RAM to .........................

endif

store data in next free space in .........................

.........................

procedure accessData()

if ......................... (data required is in RAM) then

if RAM is full then

move unneeded data from RAM to HDD

endif

move required data from HD to RAM

endif

read data from .........................

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 ..................

Input sanitisation ..................

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.

if money >= price then

venditem()

giveChange(money – price)

else

print("Error – not enough money inserted")

endif

(i) Give the identifier of one variable used in the algorithm.

[1]

(ii) State how many parameters are passed into the giveChange() subroutine.

[1]

(b) A vending machine has the following options available.

Item code Item name Price


A1 Crisps, bacon flavour £0.75
A2 Crisps, salted £0.75
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.

Draw the vending machine algorithm in the part above as a flowchart.

© 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.

studentnames = ["Rob", "Anna", "Huw", "Emma", "Patrice", "Iqbal"]

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.

Rob Anna Huw Emma Patrice Iqbal

[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.

Write an algorithm using iteration to:

• display the name of each student one at a time from studentnames


• take as input whether that student is present or absent
• display the total number of present students and number of absent students in a suitable message, after all
student names have been displayed.

[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.

pumpkin flour wall house wall

Tick (✓) one box in each row to identify whether each statement about the insertion sort is true or false.

Statement True (✓) False (✓)


The list of words is initially split into a sorted set and an
unsorted set.
The insertion sort uses a divide stage and then a
conquer stage.
The list of words must be in order before the insertion
sort can start.
Each word is inserted into the correct place in the
array, one by one.
The insertion sort will not work because the word “wall”
appears twice.
[5]
(b) A sorted list of words is shown below.

flour house pumpkin wall wall

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.

Every time she enters a value, the total is output.

The algorithm repeats until the total is over 100.

Taylor used computational thinking techniques to develop the algorithms.

Give two computational thinking techniques that Taylor has used, describing how they have been used.

[4]

27(a) Write pseudocode to increment a value held in a variable score by one.

[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.

Breaking a complex problem down into smaller problems.

Hiding or removing irrelevant details from a problem to reduce the complexity.

[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:

• input required data


• decide if the customer is entitled to a discount
• output the result of the calculation.

Design the algorithm using a flowchart.

© 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.

45 12 -99 100 -13 0 17 -27


The first step is to divide the list into individual lists of one number each. This has been done for you.

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]

(c) A linear search could be used instead of a binary search.

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.

You must use either:

• OCR Exam Reference Language, or


• a high-level programming language that you have studied.
firstName = input(“Enter a first name”)

surname = input(“Enter a surname”)

room = input(“Enter basic or premium”)

nights = input(“Enter between 1 and 5 nights”)

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.

Test data Type of test Expected output


(number of nights)
2 ALLOWED
Boundary ALLOWED
Erroneous / Invalid NOT ALLOWED
[3]

© 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.

You do not have to validate these parameters.

You must use either:

• OCR Exam Reference Language, or


• a high-level programming language that you have studied.

[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:

• OCR Exam Reference Language, or


• a high-level programming language that you have studied

[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.

The index of room represents the room number.

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

total = total + room[count]

next count

print(total)

When tested, the program is found to contain two logic errors.

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.

Write an algorithm to:

• 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.

You must use either:


• OCR Exam Reference Language, or
• a high level programming language that you have studied.

© OCR 2024. You may photocopy this page. 72 of 265 Created in ExamBuilder
[6]

32(a) The table contains four statements about programming languages.

Tick (✓) one box in each row to identify whether each statement describes a low-level programming language or
a high-level programming language.

Statement Low-level High-level


The same language can be used on
computers that use different hardware
It allows the user to directly manipulate
memory
It allows the user to write English-like
words
It always needs to be translated into object
code or machine code
[4]
(b) The variables num1 and num2 store integers.

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.

Write the missing arithmetic operator for each algorithm.

(i) Outputting 12 to the power of 2.

print(12 ……………… 2)

[1]

(ii) Working out if a number is odd or even.

number = 53

if number ……………… 2 == 0 then

print("Even number")

else

print("Odd number")

endif
[1]

(iii) Finding the difference between two measurements.

measurement1 = 300

measurement2 = 100

difference = measurement1 ……………… measurement2


[1]

© 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")

Complete the following trace table for the given algorithm.

Line number start Output

[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.

names = ["Kareem", "Sarah", "Zac", "Sundip", "Anika"]

for count = 1 to names.length – 1

pos = count

while (pos > 0 and names[pos] < names[pos – 1])

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.

Explain why the inner loop needs to be a condition-controlled loop.

[2]

(c) A bubble sort is a type of sorting algorithm.

(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]

34 Write an algorithm to play a game with the following rules.

• the player is asked 3 addition questions


• each question asks the player to add together two random whole numbers between 1 and 10 inclusive
• if the player gets the correct answer, 1 is added to their score
• at the end of the game their score is displayed.

© 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.

Fig. 2 shows part of the array, with 4 students.

For example, student 1, on Monday (day 0), played 30 minutes of computer games.

Explain why Heath is using an array to store the data.

[2]
(b)

(i) Identify a data type that could be used to store the number of minutes in this array.

[1]

(ii) State why this data type is the most appropriate.

[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.

Identify two variables used in the program.

[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.

Has been used Has not been used


Sequence

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.

Data Type Tick (✓) one box


String
Integer
Real
Boolean

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 following table shows part of this array, containing 4 students.

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.

You must use either:

• OCR Exam Reference Language, or


• a high-level programming language that you have studied.

[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.

Input Criteria (True / False)


A The customer is 15 or over
B The customer has a ticket
C The customer has the money to buy a ticket
The cinema has three screens: "Red", "Black" and "Yellow".

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.

ItemCode ItemName Price (£) Stock


GSC5 GameStation5 console 249.99 102
TV4K 4K Television 499.99 18
ABRR Audiobook reader 59.99 27
NAGC TV streaming stick 24.99 192
tblStock
Tick (✓) one box in each section to identify the correct SQL statement to select the item code and item name for
all items that have a price of £60 or over.
Tick (✓) one box

SELECT ItemCode AND ItemName

SELECT ItemCode, ItemName

SELECT ItemCode & ItemName

Tick (✓) one box

FROM tblStock

FROM table

FROM database

Tick (✓) one box

WHERE Price <= 60

WHERE Price > 60

WHERE Price >= 60

[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.

(i) Complete the design for the algorithm.

function checkdiscount(price, code)


newprice = price
size = len(discount) – 1
for x = 0 to ....................
if discount[x,0] == ................ then
newprice = ................ – discount[................]
endif
next x
............................
endfunction

[5]

(ii) Identify two variables used in this function design.

[2]

© OCR 2024. You may photocopy this page. 88 of 265 Created in ExamBuilder
(iii) Write a program that:

• asks the user for an item price and discount code


• uses the checkdiscount() function from part (i) to calculate the price of the item after any discount
has been applied
• repeats bullet points 1 and 2 until a price of 0 is entered
• outputs the total cost of all items entered, after any discounts have been applied.

You must use either:


• OCR Exam Reference Language, or
• A high-level programming language that you have studied

© 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.

StudentName Subject Grade


Alistair English 3
Jaxon Art 5
Alex Art 4
Anna French 7
Ismaael Art 9

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.

State the values output by the program on each of the lines.

Line Program code Value output


08 print (score)

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:

ItemCode ItemName Stock


A1 Crisps, bacon flavour 6
A2 Crisps, salted 2
B1 Chocolate bar 12
C1 Apple pieces 18
C2 Raisins 7

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.

newstate = input("Enter the new state : ")

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.

(i) State the value of 13 DIV 4

[1]

(ii) State the value of 13 MOD 4

[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.

Complete the function calculate

function calculate(.................................................., number)

if measurement = = "gigabytes" then

value = number * 1024 * 1024 * 1024 * 8

elseif measurement = = ".................................................." then

value = number * 1024 * 1024 * 8

elseif measurement = = ".................................................." then

value = number * 1024 * 8

elseif measure = = "bytes" then

value = number * ..................................................

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.

Every time she enters a value, the total is output.

The algorithm repeats until the total is over 100.

Write an algorithm to implement Taylor’s requirements.

[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.

(i) Complete the following flowchart to implement this algorithm.

© 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]

50(a) A programmer declares the following variables.

first = "Computer Science"


second = "is great"

State one difference between a variable and a constant.

[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]

(ii) print(second.length DIV 3)

[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]

(iii) Science is great

[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.

Function call Returned value


checkblock(2,1)
checkblock(3,0)
checkblock(2,3)
[3]

© 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]

(c) When checkblock(-1,6) is called, an error is produced.

(i) State why this function call will produce an error.

[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.

The algorithm must:

• 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.

OCR Reference Language code Selection Iteration


for i = 1 to 10
print(i)
next i

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.

01 surname = input(“Enter surname”)

02 year = input(“Enter starting year”)

03 staffID = surname + str(year)

04 while staffID.length < 10

05 ? staffID = staffID + “x”

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.

You may not need to use all rows in the table.

Line number surname year staffID Output


01 Kofi
02 2021

[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.

Arithmetic operator Purpose

[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.

continues crashes debugging error executable


high-level interpreter language low-level many
no one stops with without

Jack writes his program in a ........................................ language. This needs to be translated into assembly

or machine code before it can be executed. This is done using a translator.

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

the same position. This translator is helpful when debugging code.

A second type of translator is a compiler. This converts all of the code and produces an error report. The

code will not run until there are ........................................ errors.

The ........................................ file produced can be run ........................................ the compiler.

[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.

A typical booking record is shown in the table:

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]

(iii) Booking records are stored in a database table called TblBookings.

The following SQL statement is written to display all customer bookings that stay more than one night.

SELECT ALL

FROM TblBookings

IF Nights < 1

The SQL statement is incorrect.

Rewrite the SQL statement so that it is correct.

[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.

The following data is stored in the system:

Data stored Variable identifier Example data


The user’s name UserName Admin123
A telephone number to call when the alarm is EmergencyPhoneNumber +449999999999
activated
Whether a door sensor is activated DoorSensorActive True
Whether a window sensor is activated WindowSensorActive True
A timer that counts, to the nearest second, DoorActiveTime 100
how long a door sensor has been activated
A timer that counts, to the nearest second, WindowActiveTime 100
how long a window sensor has been
activated
Whether the system is armed SystemArmed True
Whether the system is in test mode TestModeActive True

Below is a table showing some variables within the program.

Tick (✓) one box in each row to identify the most appropriate data type for each variable.

Variable Boolean Char String Integer Real


UserName
EmergencyPhoneNumber
DoorSensorActive
DoorActiveTime
[4]

© 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.

You must use either:


• OCR Exam Reference Language, or
• A high-level programming language that you have studied.

[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

A program is written to reset the sensors. The program:


• asks the user to enter the code for the sensor they want to reset
• calls the prewritten function CheckSensorCode() to check whether the code entered is a valid code
• the sensor number is read as input if the code is valid and the function ResetSensor() is called for the
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

03 sensorNumber = input(" Please input the number of the sensor to reset")

04 sensorID = sensorType + sensorNumber

05 ResetSensor(sensorID)

06 endif

(i) Give the line number where there is concatenation.

[1]

(ii) Give the identifier of a variable used in the program.

[1]

(iii) Identify the data type of the data returned by the function CheckSensorCode()

[1]

(iv) Give the line number that contains a function call.

[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:

Date SensorID SensorType Length

05/02/2023 WS2 Window 38


05/02/2023 MS1 Motion 2
06/02/2023 DS3 Door 1
06/02/2023 MS2 Motion 3
06/02/2023 MS1 Motion 2
07/02/2023 WS1 Window 24
07/02/2023 DS1 Door 1

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.

The procedure SaveLogs():

© 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.

Write the procedure SaveLogs()

You must use either:


• OCR Exam Reference Language, or
• A high-level programming language that you have studied.

[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

The data to be stored is shown in the table.

Date SensorID SensorType Length

05/02/2023 WS2 Window 38


05/02/2023 MS1 Motion 2
06/02/2023 DS3 Door 1
06/02/2023 MS2 Motion 3
06/02/2023 MS1 Motion 2
07/02/2023 WS1 Window 24
07/02/2023 DS1 Door 1

In this table, the value of events[1, 1] contains "MS1".

(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.

Identify the process that converts integer data to string data.

[1]

(ii) Write a program that:

• asks the user to input a date


• totals the number of seconds sensors have been activated on the date input
• outputs the calculated total in an appropriate message including the date, for example:
Sensors were activated for 40 seconds on 05/02/2023

You must use either:


• OCR Exam Reference Language, or
• A high-level programming language that you have studied.

© 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.

You must use either:

• OCR Exam Reference Language, or


• a high-level programming language that you have studied.

[4]

59 A vending machine has the following options available.

Item code Item name Price


A1 Crisps, bacon flavour £0.75
A2 Crisps, salted £0.75

© 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.

The vending machine is tested before it is released.

(i) Explain the purpose of testing the vending machine.

[2]

(ii) Describe the difference between iterative testing and final testing.

[2]

(iii) Complete the following test plan for the vending machine.

Code entered Money inserted Expected result


B1 £1 Chocolate bar served, £0.10 change given
£0.85 Raisins served, no change given
C1 Error – not enough money inserted
C3 £0.75
[3]

© 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

02 for scoreCount = 1 to scores.length – 1

03 scores[scoreCount] = total + total

04 next scoreCount

05 print(total)

The function length returns the number of elements in the array.

The algorithm contains several errors.

Two types of errors in a program are syntax and logic errors.

Identify two logic errors in the pseudocode algorithm.

Write the refined line to correct each error.

Error 1 line number

Corrected line

Error 2 line number

Corrected line

[4]

62(a) Charlie is developing an adding game. The rules of the game are:

• the player is asked 3 addition questions


• each question asks the player to add together two random whole numbers between 1 and 10 inclusive

© 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.

(i) Explain why programs should be tested before use.

[2]

(ii) Complete the table by naming and describing one type of test that should be used on Charlie's program
before releasing it.

Test type Description

[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]

63 Complete the truth table for the following logic gate.

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.

Input Criteria (True / False)


A The customer is 15 or over
B The customer has a ticket
C The customer has the money to buy a ticket
Draw this system using logic gates.

[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.

The table identifies the three inputs to the computer system:

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]

(ii) A truth table can be produced for this logic circuit.

Describe the purpose of a truth table.

© 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:

Letter Input device Input of 1 Input of 0


A Motion sensor Motion is detected Motion is not detected
B Light sensor Light levels indicate it is Light levels indicate it is
daytime nighttime
C Light switch The switch is turned on The switch is turned off

The floodlight (Q) is designed to be on (Q = 1) when the switch is turned on and the motion sensor detects
motion at nighttime.

Draw a logic diagram for the floodlight.

© 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.

Truth table 1: A B Output


0 0 0
0 1 1
1 0 1
1 1 1

Logic gate 1: ........................................................

Truth table 2: A B Output


0 0 0
0 1 0
1 0 0
1 1 1

Logic gate 2: ........................................................


[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.

Statement High-level language Low-level language


Uses English-like keywords such as
print and while

Must be translated before the processor


can execute code

Code written is portable between different


processors

Requires the programmer to understand


the processor’s registers and structure

[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]

END OF QUESTION PAPER

© OCR 2024. You may photocopy this page. 133 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

1 Taking a number as input 4 1 mark for each bullet.


Using HEX subroutine correctly
Calculating Digit 1 There are no marks associated with data
Calculating Digit 2 types or conversions of data types.

INPUT decimal If used, a flowchart should represent the


digitl = decimal DIV 16 bulleted steps in the answer column.
IF digitl>=10 THEN digit1 = HEX(digit1)
digit2 = decimal - (digit1*16)
IF digit2>=10 THEN digit2=HEX(digit2)

Total 4

2 2 1 mark for each correct answer in table.

Total 2

3 a i print (hoursPlayed[0,2]) 1 Correct Answer Only

ii 1 Correct Answer Only

iii 80 1 Correct Answer Only

iv Adding all correct elements 3 1 mark per bullet to a maximum of 3.


Outputting correctly If used, a flowchart should represent the
Using a loop bulleted steps in the answer column

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

Question Answer/Indicative content Marks Guidance

b Appropriate declaration of a function 5 1 mark per bullet to a maximum of 5.


that takes day number as parameter
and returns day If used, a flowchart should represent the
Use of selection (if / switch) bulleted steps in the answer column.
Appropriate comparison
Correct identification of each day
Case default

e.g.

function returnDay(dayNo As String) As


String
switch dayNo
case 0:
returnDay = “Monday”
case 1:
returnDay = “Tuesday”
case 2:
returnDay = “Wednesday”
case 3:
returnDay = “Thursday”
case 4:
returnDay = “Friday”
case default:
returnDay = “Invalid”
endswitch
endfunction

c Loop 0 to 29 6 Accept any type of average calculation


Loop 0 to 4 (mean, median, mode).
Accessing hoursplayed[x,y]
Addition of hoursplayed[x,y] to total If used, a flowchart should represent the
Calculating average correctly outside bulleted steps in the answer column.
of loops
Outputting the results

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

Question Answer/Indicative content Marks Guidance

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

b Comparing zebra to orange 4 1 mark per bullet (multiple ways through,


Greater, so split and take right side marks awarded for appropriate comparison
Further comparison (1 or 2 depending and creation of sub groups).
on choices made)
Correct identification of zebra using
methodology above

e.g.
compare zebra to orange

greater, split right

compare to wind

greater, split right

compare to zebra

Total 8

© OCR 2024. You may photocopy this page. 136 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

5 a RebEl 1 Correct Answer Only (allow any case)

b i UitFr 1 Correct Answer Only (allow any case)

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

input firstname, surname, gender


if gender = “Male” then
username = RIGHT(surname, 3) +
LEFT(firstname,2)
else
username = LEFT (firstname,3) +
LEFT(surname,2)
end if
print (username)

Total 8

© OCR 2024. You may photocopy this page. 137 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

ii 1 mark for each completed piece of code 5 For messageLength - 1 in loop


AO3 2b accept messageLength or
message = input("Please enter (5) message.length
your string")
newMessage = "" Spelling must be exact, do not penalise
messageLength = message.length case.
for count = 0 to messageLength
– 1// message.length – 1 Examiner’s Comments
ASCIIValue =
ASC(message.subString This question tested candidates'
count,1)) understanding of algorithms and the use of
ASCIIValue = ASCIIValue + 1 strings in programming.
if ASCIIValue > 90 then
ASCIIValue = ASCIIValue – A noticeable number of candidates did not
26 attempt the question.
endif
newMessage = newMessage & The most common correct response was
CHR(ASCIIValue) the first space to identify the number of
next count iterations. The final space was also often
answered correctly, identifying that the
string is concatenated with the rest of the
message.

Fewer candidates were able to identify the


character being selected, or the value to
add to ASCIIValue within the loop.

© OCR 2024. You may photocopy this page. 138 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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

Accept any output method

Bod - if the candidate outputs


something extra it must be valid i.e. a
variable from the program, or additional
text in a string with suitable
concatenation e.g.
print(newMessage +
asciiValue) is ok but
print(newMessage is the new
message) is not.

Examiner’s Comments

This question required candidates to


identify the variable from part bii that stores
the final encrypted message and to output
it using any identifiable output keyword.

A common error was putting speech marks


around new message i.e. ‘newmessage’
which would mean the words
‘newmessage’ would be output instead of
the contents of the variable.

Total 8

© OCR 2024. You may photocopy this page. 139 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

Most candidates were able to complete this


successfully for at least some values.

Where mistakes were made, these tended


to be with the last set of values and the
decision as to whether 12 is less than 12,
which should be evaluated to be False.

Candidates gained a good understanding


of this algorithm through this question
which was then intended to lead onto the
next question.

b 1 mark per bullet to max 6. 6 Question specifically asks for pseudocode.


AO3 2b
Inputs two value (as X and Y) (6) Outputs should only be given if they occur
Compares if X is larger than Y… with the right condition(s).
…Outputs Y*X only when False
Compares if X is less than 12… Example algorithm
…Outputs X only when True and X
>Y input x
…Outputs Y only when False and X input y
>Y if x > y then
if x < 12 then
print x
else
print y
end if
else
print y*x
end if

Variables do not have to be called x and y.

Accept equivalent comparisons (e.g. if X


<= Y)

Allow FT for outputs from incorrect


comparisons where a sensible attempt has

© OCR 2024. You may photocopy this page. 140 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Please note how mark bullet points match been made.


up to the flowchart given in the question.

BP1 is for taking both inputs

BP2 and 4 are for correct comparisons of


variables. This may be done in alternative
ways (e.g. X<=Y, X>=12, etc)

BP3, 5 and 6 are for the correct outputs in


the right place.

If the answer logically works to produce the


correct output, it should be marked as
correct.

Examiner’s Comments

This question asked candidates to


translate the given flowchart into
pseudocode. It should be noted that no
specific format for pseudocode is
expected; candidates may use any code-
like format that they choose as long as this
conveys the logical intention of the
solution.

Large numbers of candidates achieved full


marks on this question and candidates who
explored the whole of the algorithm were
likely to do very well.

By comparison, candidates who attempted


to convert each box of the flowchart into
lines of pseudocode strictly from top to
bottom often fell foul of the False outcome
from the first decision being in the wrong

© OCR 2024. You may photocopy this page. 141 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

place.

The most common issue here was a lack


of understanding that the opposite of X>Y
is not simply X<Y; this does not cater for X
being equal to Y. Where candidates put X
<=Y or equivalent, this was accepted.

This logical issue was also frequently


repeated on the second decision for X<12.

Exemplar 1

In Exemplar 1, the candidate has logically


hit every point from the flowchart and
converted this successfully into
pseudocode. This response achieved 6
marks.

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.

Interpreter Most candidates were then further able to


…translates code line by line. describe the methods used by these
…will be interpreted / translated every translators, such as interpreters translating
time it is run. code line-by-line.

It is pleasing to see that this section of the


specification is obviously well understood
and generally answered with confidence.

Total 14

© OCR 2024. You may photocopy this page. 142 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

8 a i 1 mark per bullet to max 1 1 Do not accept examples of logic errors.


AO1 1b
An error that results in incorrect output (1) Examiner’s Comments
/ unexpected result
Contains an error but still runs / doesn’t This question asked candidates to state
crash the meaning of the term ‘logic error’.

To be successful, candidates needed to


show examiners that they knew how a
logic error differed from other types of
errors and so answers such as ‘when code
does not work’ were not precise enough.

Successful answers conveyed the idea of


incorrect output without stopping the
execution of the program.

ii if num MOD 2 == 0 then 1 Important point is that >= is changed to ==


AO3 2b or =.
if num MOD 2 = 0 then (1) Accept alternatives that produce the same
result (e.g. <=0, <1, !=1, etc.)

Ignore any casting (e.g. using int() to


convert to a number)

Accept other minor changes to the line as


long it logically works.

Accept versions of MOD from high level


languages (e.g. Python : if num % 2 ==
0)

Examiner’s Comments

The logic error present in the program was


that any number entered would print out
‘even’ because line 02 checked if num MOD
2 was greater than or equal to 0 rather
than simply equal to 0. This could be fixed
by replacing the greater than comparison
with an = (or == ).

Few candidates achieved this, suggesting


a lack of confidence either with the MOD
operator or the program as a whole.

b i 1 mark per bullet to max 1 1 Do not accept examples of syntax error


AO1 1b (e.g. misspelling).
An error in the grammar of the program (2)
// error that breaks the rules of the

© OCR 2024. You may photocopy this page. 143 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

programming language Examiner’s Comments


Contains an error but will not run /
translate / execute This question asked candidates to state
the meaning of the term ‘syntax error’.

To be successful, candidates needed to


show examiners that they knew how a
syntax error differed from other types of
errors and so answers such as ‘when code
does not work’ were not precise enough.

A very common incorrect answer here was


to explain what caused the syntax error in
this code or to give general examples of
things that would cause syntax errors (e.g.
‘a misspelling of a word’) and not to give
the wider answer of an error that breaks
the grammatical rules of the programming
language.

Exemplar 2

In Exemplar 2, for example, the response


given by the candidate above could equally
apply to logic errors and is therefore
assessed to be too vague. This was given
0 marks.

AfL

Candidates should make sure that they


read questions carefully to ascertain
whether a contextual basis is required in
their answer.

‘What is meant by a syntax error’ is a very


different question than ‘what caused the
syntax error in this code’.

Examiners mark against a given mark


scheme and even when candidates show
understanding, this can only be credited if
the question on the paper has been
answered.

© OCR 2024. You may photocopy this page. 144 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

ii print(“odd”) 1 Must include quotes (single or double). Do


AO2 1b not penalise spelling mistakes in message.
(1) Accept sensible alternatives to “odd”
Accept alternatives for print / output as
long as spelling is accurate

Examiner’s Comments

This question was answered extremely


well as the majority of candidates were
able to identify and fix the misspelling of
the keyword ‘print’ in their answer.

The small number of candidates who did


not manage to successfully answer this
question tended to try to expand their
answer beyond simply fixing the error.
They then introduced new errors or
unnecessary code. Where additional code
was given, if it logically worked then this
was accepted.

Total 4

© OCR 2024. You may photocopy this page. 145 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

9 a i 1 mark per bullet to max 2 2 Accept answers relating to using fewer


AO1 1a computational resources
Removing / hiding / obscuring (1)
unnecessary detail AO1 1b Must be the programmer making the
Focusing on the important detail (1) decision.
Simplifies the problem // reduces
complexity // Easy to solve /
understand

ii 1 mark per bullet to max 1 1 Mark first answer only


AO2 1a
Suitable example of what can be (1) Allow any suitable example of abstraction
focused on (e.g. player name, match as long it is relevant to the system.
results, goals scored)
Suitable example of what to Allow either first name or surname to be
remove/hide (anything relevant that is removed as an example, but do not allow
not results/goals scored) both to be removed.
Suitable example of a simplification
made Examiner’s Comments

As a topic new to the J276 specification,


abstraction as a concept is obviously well
understood by candidates who were
generally able to give a definition for (i)
around removing unnecessary detail and
focussing on the important details in a
problem.

A small number then went on to state that


this is done to simplify a problem or reduce
complexity which shows a perhaps deeper
understanding.

Answers for (ii) were slightly less well


completed as answers had to be linked to
the scenario given; examiners were
generous in their interpretation and
accepted a wide range of answers that
could potentially be removed or focused
on.

© OCR 2024. You may photocopy this page. 146 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

b 1 mark per bullet to max 3 3 Correct answer only.


AO3 2b
count (3) Accept alternatives to adding 1 to variable
= nogoalscount + 1 (e.g. += 1 / ++)
nogoalscount
Penalise spelling once only, FT for further
mistakes. Do not penalise case.

Accept sensible messages printed out


alongside nogoalscount

Examiner’s Comments

This question assessed whether


candidates were able to complete an
algorithm to count the number of times that
the value 0 appeared in a given array.

The first blank to be filled in tested


candidates’ understanding of the use of a
for loop counter to access each index in an
array sequentially; this was not answered
successfully by many candidates and
perhaps shows a lack of understanding.

The next blank was more successfully


answered and required candidates to
increment the variable by 1 which could
have been done in several ways, all of
which were accepted.

Finally, the simplest and most commonly


correct answer simply required candidates
to print out the value of the variable.

Total 6

© OCR 2024. You may photocopy this page. 147 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

10 a i 1 mark per bullet to max 6 6 Bullet points 3, 4, 5 can be awarded even if


AO3 2b no mention of a function / parameters (for
Function ticketprice() defined (6) example, if candidate has inputted the
… that accepts two parameters and number of tickets needed.
has no other inputs
Works out total ticket price for adult (eg Do not award return value if no attempt at
adult * 19.99) a function. Return mark can be given if a
Works out total ticket price for children good attempt made at calculating the total,
(eg child * 8.99) even if this is incorrect.
Adds on correct booking fee
Returns the calculated value. Allow 2.50 booking fee to be per order or
per ticket

Ticket prices must be stored appropriately


if needed.

example algorithm

function ticketprice(numadult,
numchild)
price = (numadult * 19.99) +
(numchild * 8.99) + 2.50
return price
end function

Allow alternatives in high level languages


(e.g. def in Python).

Allow return as assigning the value to the


name of the function (VB syntax)

Examiner’s Comments

This question assessed not only whether


candidates could create an algorithm to
calculate a ticket price using the
information given, but also whether this
could be done as a function.

Many candidates were able to achieve the


first part of this well, but only a small
number even attempted to create this in
the form of a function with parameters
passed in.

Most candidates chose to ask for inputs


during the algorithm instead of passing
parameters and were therefore only able to
achieve a maximum of 3 marks out of 6.

© OCR 2024. You may photocopy this page. 148 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Misconception

A function should not take input directly


from the user; instead, values required
should be passed in as parameters.

Equally, when the required calculations are


completed the value should not be printed
out but returned.

Using parameters and returned values in


this way makes a function truly reusable.

Exemplar 3

Exemplar 3 shows a response that


successfully covers all of the points
required by the question and therefore
achieves 6 marks.

Exemplar 4

The response above shows a response


that only managed to gain 2 marks, for the
calculation of the total price for adults and
the total price for children.

There is no attempt to use a function and


the input/outputs are done through inputs

© OCR 2024. You may photocopy this page. 149 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

and print statements rather than


parameters passed and a value returned.

In addition, the booking fee was not


correctly added to the overall price as the
assignment statement is the wrong way
around.

ii 1 mark per bullet to max 2 2 Allow String only if matching justification


AO2 1a shows understanding (e.g. £ sign attached,
Real… (1) message returned alongside value).
…Returned value may not be a whole AO2 1b
number / may have a decimal point in (1) Examiner’s Comments

The majority of candidates answered this


well, with Real being chosen because of
the potential need to use decimal places in
the value returned as the main correct
answer.

Where candidates had justified the use of a


string (because the returned data would
include currency symbols or other text) this
was also credited.

b 1 mark per bullet to max 1 1 Mark first answer only


AO2 1b
Check that the code is valid / real (1) Examiner’s Comments
Check it has been entered / sent /
received correctly. This question asked candidates to give a
Makes it harder for people to make up benefit of using a check digit for a discount
discount codes code that had been emailed out to
customers.

A check digit is used to make sure that


data has been transmitted, received or
entered correctly into a computer system
and so answers around this point were
expected.

Where candidates went further and said


that this therefore meant that discount
codes could not be falsified or made up,
this was accepted as the same main idea.

A very common wrong answer was so that


the discount code could not be used again
or was somehow unique to each user,
showing a lack of understanding as to the
use of check digits in computer systems.

© OCR 2024. You may photocopy this page. 150 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

c i Not in order / sorted 1 Mark first answer only


AO2 1b
(1) Examiner’s Comments

This question required candidates to


understand that one of the pre-requisites of
a binary search is that the data must be in
some form of order. Where this was
understood, candidates were able to
identify that the data presented was not in
order and so could be searched using this
algorithm.

Extremely common wrong answers


included that only numeric data could be
used or that data had to be in binary.

Misconception

A binary search can be carried out on non-


numeric data.

If the data is ordered in some way (e.g.


alphabetically) then this algorithm will be
able to efficiently find data.

ii Linear (search) 1 Mark first answer only


AO1 1b Allow other valid searching algorithms as
(1) long as they work on an unsorted list (e.g
front and back search)

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.

This proved to be a very tough question,


with the majority unable to explain its use
as a flag to store whether a swap had
taken place during that pass, and then
further as a condition to check whether to

© OCR 2024. You may photocopy this page. 151 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

repeat lines 03 to 11.

Many candidates understood, perhaps


through the name given to the variable,
that it was involved in swapping something,
but many said that the variable itself made
the swap, which is logically incorrect.

Some candidates seemed to not


understand the while loop on line 02.

Misconception

A while loop, as its name suggests,


repeats while a condition is True.

For example, while x>5 will repeat while


the condition x>5 is evaluated to be True.

However, if the condition given is itself a


Boolean value, then no evaluation is
necessary, and the True of False nature of
this condition is used to decide whether to
repeat or not.

In this question, swaps is a Boolean value.

The line while swaps is logically


equivalent to the more verbose and
unnecessary while swaps == True

Exemplar 5

The above response shows a typical


answer where the candidate has not quite
understood the process undertaken by the
bubble sort algorithm; swaps is set to True
when a swap has occurred and not, as this
candidate suggests, that the swap occurs
because of the variable being set.

© OCR 2024. You may photocopy this page. 152 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

ii 1 mark per bullet to max 2 2 Do not accept “sorts numbers”


AO2 1b
Swaps.. (2) “swaps numbers” meets BP1. Explanation
…values of queuesize[p] and of which values in the array are swapped
queuesize[p+1] meets BP1 and BP2.
…when queuesize[p] is larger than
queuesize[p+1] Do not accept direct word for word
using a temporary variable //doesn’t repetition from the program (e.g. temp =
overwrite numbers //explanation of queuesize[p] ) , question asks for an
process explanation.

Explanation of temporary variable must be


logically correct.

Examiner’s Comments

This was another question where


candidates struggled to explain clearly the
purpose of a specific part of the given
algorithm.

Lines 06 to 08 dealt with swapping two


values over. Simply identifying that swap
takes place and which numbers are
swapped was sufficient to achieve both
marks here, but the majority were unable
to successfully do this.

A mark could also have been given for


explaining that the two numbers were not
directly swapped over, but that a temporary
value was used as an intermediary.

Many candidates provided answers that


were entirely different from this. In some
cases, candidates attempted to simply
translate each line into structured English.

© OCR 2024. You may photocopy this page. 153 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

iii 1 mark per bullet to max 2. 2 Mark first answer only


AO2 1a
Comments (1) Do not accept indentation (already done)
… to enable programmers to AO2 1b
understand the purpose of each line / (1) Accept “show what each line does” for
section comments.
…by example (e.g. on line 4 add the
comment…) Examiner’s Comments

Naming variables sensibly Maintainability is obviously well understood


… to enable programmers to by centres and students, with many
understand the purpose of each students giving very pleasing answers to
variable this question.
…by example (e.g. change identifier p
to …) Commenting and the need for comments
was perhaps the most popular answer.
Modularise
…to allow reuse / makes easier to test It was nice to see modularisation
/ reduces errors discussed also, although a number of
…by example (e.g. create as a students were unable to explain what they
function) meant by this and how it could be applied
to the code given.

© OCR 2024. You may photocopy this page. 154 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

iv 1 mark per bullet to max 2. 2 Accept “insert”. Do not penalise spelling.


AO1 1a
Insertion (sort) (2) Do not accept bubble sort (given in
Merge (sort) previous questions)

Do not award searching algorithms

Allow other valid sorting algorithms.


(e.g. quick sort, heap sort, shell sort,
selection sort, radix sort, bucket sort, tim
sort, comb sort, pigeonhole sort, etc.)

Examiner’s Comments

This question was answered extremely


well by candidates and shows that the
prescribed sorting algorithms are covered
in centres and their names retained well by
candidates.

Merge sort and insertion sort are the two


other algorithms covered in the
specification and these were the two most
popular answers given by candidates.
However, credit was also given to many
other valid sorting algorithms and it is
pleasing to see that centres or candidates
are interested in going beyond the confines
of the specification to investigate
algorithms such as Quick sort (which
appears in the A Level specification) and
even Bogo sort. This additional learning is
to be applauded.

© OCR 2024. You may photocopy this page. 155 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

e 1 mark per bullet to max 8. 8 Answers can be in any suitable format


AO3 2b (including pseudocode, flowchart, etc). If
Input height (8) flowchart used, accept any sensible
Accepts riders > / >= 140 with suitable shapes.
message
Rejects riders < / <= 120 with suitable Do not penalise for lack of initialisation of
message variables.
Checks if height between 120 and
140… Loop must repeat until 8 riders allowed, not
… If True, input whether accompanied just loop 8 times.
… Suitable output message for True
AND False Do not credit asking whether accompanied
Correctly counts number of riders in all if in the wrong place.
cases of being allowed to ride (do not
penalise candidates for counting or not Condition for BP4 may be 120 < h <
counting accompanying adults) 140
Attempt to loop based on 8 riders
allowed Example algorithm
riders=0
while riders <8
input height
if height >= 140 then
output “allowed”
riders = riders + 1
elif height >=120 then
input withadult
if withadult == “yes”
output “allowed”
riders = riders + 1
else
output “not allowed”
end if
else
output “not allowed”
end if
endwhile

Examiner’s Comments

This question asked candidates to create


an algorithm for checking the heights of
riders on a theme park ride.

The algorithm was decomposed for


candidates using bullet points and many
candidates had a solid attempt at
completing this.

Most candidates were able to ask for the

© OCR 2024. You may photocopy this page. 156 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

input of a rider’s height, although some


candidates struggled to use (or missed out)
either the assignment operator or the
INPUT (or equivalent) command. A line of
pseudocode that simply printed out ‘enter a
height’ is not the same logically as an input
and was not credited.

Where an input was taken and


comparisons made, these were generally
well attempted.

Examiners worked logically through the


code and credit was given for checking for
the three types of riders (over 140 and so
can ride alone, between 120-140 and so
need to ride with an adult, under 120 and
so cannot ride) and giving the right output
to each rider.

There were many different valid and invalid


attempts at this but logically, if each type of
rider would have produced the right output
then this should have been credited. The
mark scheme provides an exemplar
answer, but a wide range of responses
were accepted.

Many candidates did not attempt to repeat


the algorithm until 8 riders had been
allowed to ride and so were unable to
access these marks. However, several
higher ability candidates thought even
more deeply about this and wrote
algorithms that added two riders if
someone was riding with an adult; this was
a valid thought and so was credited as
well.

© OCR 2024. You may photocopy this page. 157 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Exemplar 6

Exemplar 6 shows a well organised


response that gained full marks. Each
check is completed in order, with ELIFs
and ELSE used efficiently to make sure
that logically correct comparisons are
made. The loop works correctly and
repeats until 8 riders have been allowed to
ride. This is a very good example of the
sort of response needed to achieve highly.

Total 28

© OCR 2024. You may photocopy this page. 158 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

11 a 4 1 mark for each row from rows 2–5. Allow


(AO2 1b) multiple swaps in one stage, where it is
clear that a bubble sort has been applied.

b Comparing zebra to orange 4 1 mark per bullet (multiple ways through,


Greater, so split and take right side (AO2 1b) marks awarded for appropriate comparison
Further comparison (1 or 2 depending and creation of sub groups).
on choices made)
Correct identification of zebra using
methodology above

e.g.

compare zebra to orange

greater, split right

compare to wind

greater, split right

compare to zebra

Total 8

© OCR 2024. You may photocopy this page. 159 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

12 a i or 3 High-level programming language / OCR


>300 // >= 301 (AO3 2b) Exam Reference Language response
print required

Do not accept pseudocode / natural


English.

MP2 do not accept ‘greater than’, must use


the HLL syntax > or >=
MP3 must be a suitable output command
word that could be found in a HLL e.g.
print (Python), console.writeline
(VB), cout (C++)

ii Suitable invalid test data (i.e. > 300, 3


e.g. 350) (AO3 2c)
Suitable boundary test data (e.g. 0,
300)
"Value accepted" or equivalent if
boundary data 0 or 300 // "Invalid input
displayed" or equivalent if boundary
data -1 or 301

b 4 one mark for first row


(AO3 2c)
one mark for row 2 and 3

one mark for rows 4, 5, and 6

one mark for the correct output (the only


value in the output column, in any position)

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

Question Answer/Indicative content Marks Guidance

d i Input 2 Enter text here.


(AO3 2a)
Number of hours and minutes

Output

Number of minutes

ii Program calls function correctly using 4 hours = input("Please enter


hours and minutes variables (AO3 2a) number of hours played")
Parameters used appropriately
Calculation is computed accurately minutes = input("Please enter
Final total is returned suitably number of minutes played")

finalTotal = totalMins(hours,
minutes)

print (finalTotal)

function
totalMins(hours,minutes)

total = hours + mins * 60

return total

endfunction

1Parameters named in function must be


used within the function itself
2Does not matter if function uses
different names to those declared in
main program
3Return must be included with the
correct local variable for total

© OCR 2024. You may photocopy this page. 161 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

Example algorithm given below

minutes = input("Enter minutes


played")
if minutes > 120
print "You played games for
too long!"
else
print "You are under your
time limit!"
endif

Accept alternative (but suitable) output


messages.

Accept logical comparison of input less


than or equal to 120 and appropriate
True/False statements.

Total 24

© OCR 2024. You may photocopy this page. 162 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

13 a 1 mark per bullet, max 4 4 D, F may be swapped around.

C e.g.
A
D/F
F/D

b i An error that does not cause the 1


program to crash // produces
unexpected output

ii 1 mark per bullet, max 4 4 Mark in pairs

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)

ii 1 mark per bullet, max 2 2 Do not accept answers relating to "end of


list" – this is linear search.
List of size 1 to compare
…and item not matched to search term

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

Question Answer/Indicative content Marks Guidance

14 Logically compares A AND // correct 3 A = input("Is the customer 15


nested IF or over?")
…B OR C // correct sequential IF B = input("Does the customer
Output in both cases (with attempt at have a ticket?")
selection). C = input("Does the customer
money to buy a ticket")
if A AND (B OR C) then
print ("allowed")
else
print ("not allowed")
endif

Accept answers where inputs are given as


strings e.g :

if A == “Yes” AND (B == “Yes”


OR C == “Yes”) then
print ("allowed")
else
print ("not allowed")
endif

Total 3

© OCR 2024. You may photocopy this page. 164 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

15 a i Hiding / ignoring / removing detail // 1


focussing on certain parts of a problem

ii Focus on age / number of miles 1 Allow other examples of factors to ignore /


Ignore other factors (such as make, remove for BP2
model, etc)

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.

miles = input("enter miles


driven")
age = input("enter age of car")
valid = True
if miles > 10000 or miles < 0
then
valid = False
elseif age > 5 or age < 0 then
valid = False
endif
print(valid)

ii 1 mark per row, max 3 3 Specific data must be given, not a


description
Normal : miles (0 – 9,999), age (0 - 5) e.g.
Erroneous: miles (less than 0, larger
than 9,999), age (less than 0 / more
than 5) // non-numeric data
Boundary : miles (-1/0 / 9,999 / Miles Age
10,000), age (-1/0 / 5/6)
Normal 7,000 3
Erroneous 12,000 7
Boundary 10,000 5

© OCR 2024. You may photocopy this page. 165 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

iii During development // whilst writing the 1


program // before development is
complete.

c 1 mark per bullet, max 6 6 Allow output of 0 hours 0 minutes if full.


Allow answers referencing decimal parts
Inputs the current battery charge (e.g. 0.8 = 80%)
percentage BP5 can be attempted in many ways (e.g.
Outputs “full” if 100% DIV and MOD, repeated division, etc)
Calculates the amount to charge Allow FT for BP6 if reasonable attempt at
Calculates the time in minutes… conversion for BP5 has been given.
…converts to hours and minutes
Outputs the time in hours and minutes e.g.
charge = input("enter battery
charge")
if charge == 100 then
print(“full”)
else
time = (100-charge) * 10
hours = time DIV 60
mins = time MOD 60
print (hours, mins)
endif

Total 19

© OCR 2024. You may photocopy this page. 166 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

16 a i One mark if two correct, two marks if four 3


correct, three marks if all correct.

Price input Test type Expected


price output
50 Normal 50
100 Boundary 100
150 Normal 130
200 Boundary 180
250 Normal 210

ii One mark per bullet point 6 High-level programming language / OCR


Exam Reference Language response
Input and store price required
Check if price is > 200…
…if true, reduce price by 40 Do not accept pseudocode / natural
Check if price is >100 and not >200… language.
...if true, reduce price by 20
Output price BP3 and BP5 only to be given if sensible
check for price being over the appropriate
threshold. BP4 must check that price is
both larger than 100 and not larger than
200; do not give mark for simply checking
price is larger than 100. This may be
implicit (e.g. using elseif).

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

Question Answer/Indicative content Marks Guidance

b One mark per bullet point 5 High-level programming language / OCR


Exam Reference Language response
checking both values (e.g. or changed required
to and if appropriate)
if statement in correct format (e.g. Do not accept pseudocode / natural
checking against stocklevel for language.
each condition)
if statement uses correct e.g.
comparisons (e.g. >= and <=)
print statements in correct position stocklevel = input("Enter stock
print statements include string level")
delimiters (e.g. speech marks) around if stocklevel >= 5 and
both string outputs stocklevel <= 25 then
print("In demand")
else
print("Not in demand")
endif

alternative example

stocklevel = input("Enter stock


level")
if stocklevel > 5 or stocklevel
> 25 then
print("Not in demand")
else
print("In demand")
endif

As a matter of principle, a candidate who


refines the program to work fully but in a
different format to that specified should
gain full marks.

Total 14

© OCR 2024. You may photocopy this page. 168 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

17 a 2 1 mark for each correct answer in table


A B P (AO1 1b)
‘True’ or ‘T’ are also credit worthy.

b 1 Correct Answer Only


(AO1 1b)

Total 3

18 a • if 4 Allow equivalent pseudocode expressions


• num2 (AO3 2b) Variables must not have speech marks
• print (num1) around them
• print (num2)

b use of condition controlled loop (while 5 e.g. 1


or do/until)… (AO3 2b) store 10 in number
…checking condition of number larger while number is greater than or equal to 0
than or equal to 0 do the following:
Input number from user within loop (FT Take input from the user, store in number
if no loop) Multiply number by 2
multiply number input by 2… Output number
….output value in number
e.g. 2
while number >= 0
number = input()
output(number * 2)
Ignore non-initialisation of value used in
condition for loop.

Total 9

© OCR 2024. You may photocopy this page. 169 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

19 a RebEl 1 Correct Answer Only (allow any case)


(AO2 1b)

b i uitFr 1 Correct Answer Only (allow any case)


(AO2 1b)

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

20 a To convert it to binary/machine code 1 Maximum 1 mark


The processor can only understand (AO1 1a)
machine code

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

Question Answer/Indicative content Marks Guidance

21 1 mark for each letter in the correct place 6

procedure storeData()

if RAM is C/Full then

move data from RAM to A/Secondary


Storage

endif

store data in next free space in H/RAM

F/endprocedure

procedure accessData()

if B/NOT (data required is in RAM) then

if RAM is full then

move unneeded data from RAM to HDD

endif

move required data from HD to RAM

endif

read data from H/RAM

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

Question Answer/Indicative content Marks Guidance

23 a i money 1 Must be an identifier, not description.


price Ignore case.
AO1
1b(1)

ii one 1 Examiner’s Comments


Question (b)(i) was answered very well.
AO2 However, (b)(ii) was only answered
1b(1) correctly by a small proportion of
candidates. These were also the
candidates who generally went on to
achieve high marks on this paper.

The question asked candidates to state


how many parameters are passed into the
function from the line giveChange(money
– price). Two variables are inside the
brackets. Candidates did not recognise this
as a calculation.

This calculation would be completed before


the function call. Only the result is passed
into the function as the parameter. This
means that the correct answer is one. Most
candidates gave the (incorrect) answer of
two.

Misconception

Where a sub program (function or


procedure) has multiple parameters
passed into it, there will be separated by
commas – for example
testfunction(x,y). A subprogram with
a calculation as a parameter will pass the
result of this calculation into the sub
program.

© OCR 2024. You may photocopy this page. 172 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

b 1 mark per bullet 5 Reasonable attempt at BP1 needed for


credit BP2, 3 and 4 Ignore other additional
Checking if money>=price… AO3 code.
…decision (diamond shape) used 2b(5)
…venditem() and BP3 and BP4 must follow on from
giveChange(money-price) if True/False // Yes/No decision to be
True/Yes credited.
…output an error if False / No
Terminator used to start and end the Subroutines names and parameters must
program and all paths terminated be correct. Ignore missing brackets on
venditem.

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.

A typical answer for this question would be


good to use for centres when teaching
about using flowcharts. Candidates who
use flowcharts for algorithm answers are
often not specific enough with the steps
required. This gives answers that are
generic or high-level. The structure of this
question is a good example of the level of
detail required.

© OCR 2024. You may photocopy this page. 173 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

c i 1 mark per bullet to max 2 2

Indentation // whitespace AO2


Appropriately named variables / 1b(2)
identifiers
Modularisation / use of subroutines

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

Question Answer/Indicative content Marks Guidance

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

c Use of iteration (any use) … 6 BP 2 and 3 may be met together with


…loops for each item in array // loops 6 suitable input statement. Both dependent
times AO3 on attempt at iteration.
…to print out each item in 2b(6)
studentnames BP5 not dependent on correct previous
…input attendance parts.
Add up/calculate students present and
absent BP6 needs reasonable attempt at totalling
…Outputs present and absent (in present and absent figures.
suitable message)
Ignore non-initialisation of counter
variables.

Flowcharts are acceptable but must show


how to solve the problem, not simply
repeat the question.

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

Question Answer/Indicative content Marks Guidance


next i

print ("Present students: " + present)

print ("Absent students: " + absent)

Examiner’s Comments
Question (c) asked candidates to write an
algorithm to:

1. Call an attendance register from a given


array.
2. Count and output how many students
were present and absent.

It was pleasing to see candidates


decompose the problem and tackle each
part to build a full solution.

The bullet points given in the question


served as a scaffold.

Where one section was incorrect, other


marks could be given.

A number of candidates attempted to use a


FOR…IN loop to iterate over the given
student array.

FOR…IN is not listed in the specification but


is an entirely suitable way to approach the
problem. Where this was logically sound,
full marks were available.

Other candidates used FOR…NEXT loops


or WHILE loops in conjunction with the
length of the array. Again, marks were
given where the solution was logically
sound.

Marks were more limited for those


candidates who did not attempt any sort of
loop, but some were still able to be given
where appropriate.

AfL

Centres should be encouraged to connect


together content within the specification, so

© OCR 2024. You may photocopy this page. 176 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

that rather than teaching arrays in isolation,


they could perhaps be combined with
iteration to be able to count up or total
values in an array, or apply this to how
searching and sorting algorithms work.
Where this is done on a regular basis,
questions such as 6(c) perhaps become
less daunting for candidates.

OCR support

Appendix 5f of the current J276


specification covers the pseudocode guide
for this examination. Candidates do not
need to use this in their responses but they
should be aware of this as questions will
be presented using this format.

For the new J277 specification, this has


been replaced by OCR Exam Reference
Language. This is detailed from page 25
onwards.

Total 15

© OCR 2024. You may photocopy this page. 177 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

25 a Statement True (✓) False (✓) 1 1 mark per row


The list of ✓
words is initially
split into a
sorted set and
an unsorted set
The insertion ✓
sort uses a
divide stage
and then a
conquer stage.
The list of ✓
words must be
in order before
the insertion
sort can start
Each word is ✓
inserted into the
correct place in
the array, one
by one
The insertion ✓
sort will not
work because
the word “wall”
appears twice.

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

This question was asked candidates to


explain how a binary search would work to
find the value “house” in the given list.
Where candidates did this well and
explained each step, using the list given,
full marks were often attained.

© OCR 2024. You may photocopy this page. 178 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

However, a number of candidates instead


ignored this list and gave a generic answer
such as “pick the middle value, if this is not
the one you want, check if this value is
larger or smaller than the one you are
looking for”. This did not hit many points on
the mark scheme.

A much better answer would refer to the


middle value in the given list (“pumpkin”),
noting that “house” is alphabetically before
this so the right half of the list could be
removed / ignored, leaving the new list as
[“flour”, “house”]. A candidate could then
go on from this point to achieve full marks.

A small number of candidates confused


linear and binary search. Other candidates
referred to splitting the list in half without
discussing any form of comparison.

AfL

It is important to link scenarios to


responses when required. This is
particularly important if a question
specifically asks for this as part of the
answer (such as Question 2(d) above,
“Explain how a binary search would be
used to try to find whether the word
“house” appears in this list.”)

Total 9

© OCR 2024. You may photocopy this page. 179 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

26 e.g. 4 Mark in pairs. 1 mark for name, 1 mark for


description.
Abstraction Description must match technique (if
⋯ focussing on the important elements given).
// ignoring elements that do not
contribute to the solution // simplifying Examiner’s Comments
the problem This question was asked candidates to
Decomposition describe computational thinking techniques
⋯breaking a problem down (into its that had been used to develop the
constituent parts) algorithm. This was done extremely well by
Algorithmic thinking the majority of candidates and it is clear
⋯set out the steps needed to solve the that this has been taught very well
problem // represented in a flow chart / nationally.
as pseudocode
Most candidates were able to name two
suitable techniques and many were also
able to describe what these techniques are
used for.

Total 4

© OCR 2024. You may photocopy this page. 180 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

27 a score = score + 1 // score 1 Allow other logically correct answers that


+=1 // score++ (AO3 2b) result in score increasing by one and being
overwritten. Do not accept score + 1 /
score = +1

Accept valid structured English answers


that refer to score increasing and
overwriting the existing value by one. e.g.
“score becomes/equals score plus one”

Ignore any superfluous code that does not


affect the outcome

Examiner’s Comments

Most candidates were able to temporarily


add one to the value of score (by using
code such as score + 1). Fewer were
able to assign this new value to the
variable of score and therefore fully answer
the question. Answers such as score =
score + 1, score++ or score +=
1 were all accepted, as were any longer
responses that used intermediate
variables. As long as the value of score
ended up being incremented by one,
examiners were instructed to give credit.

Assessment for learning

One notable response that was not allowed


was score =+1. This statement assigns the
value of ‘positive 1’ to score, overwriting
the previous value held.

This is a good example of the precision


required to gain marks. Candidates with
practical programming experience are
more likely to recognise this.

© OCR 2024. You may photocopy this page. 181 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

b Decomposition 2 Correct answer only. Ignore spelling errors.


Abstraction (AO1 1a)

Examiner’s Comments

This question was answered well by the


majority of candidates.

Total 3

© OCR 2024. You may photocopy this page. 182 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

28 a Start and end/stop with all boxes 5


connected, no boxes that do not lead (AO3 2a)
to another box (no arrows needed)
Input three variables using
parallelogram shape
Checks all three criteria (day, student,
discount card) using diamond shape(s)
with two lines from each
…Outputs “full price” with correct
conditions using parallelogram shape
…Outputs “half price” with correct
conditions using parallelogram shape

Guidance for correct outputs

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.

Inputs / decisions may be presented as


individual or combined boxes but must still
store as three variables.

Penalise lack of parallelogram for


input/output once only then FT

BOD parallelogram shapes if not sure


whether input or output as long as context
is clear (e.g inputs at start, outputs at end)

© OCR 2024. You may photocopy this page. 183 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Examiner’s Comments

Most candidates who answered this


question were comfortable using the
correct flowchart symbols listed in the
specification. A mark was available for
including suitable start / end symbols and
connecting all other symbols, so even
candidates who may struggle should feel
confident of being able to access some
marks.

Marks were dropped when responses did


not include suitable inputs to the algorithm.
The first bullet point in the question stem
was clear that these were required.

Candidates achieving lower scores tended


to group decisions so that any processing
was removed (such as “can they have a
discount?”). More successful responses
decomposed the problem and used a
succession of smaller decisions (“do they
have a discount card?”, “are they a
student?”, “is it Saturday?”). These
decisions then point towards the correct
outputs.

© OCR 2024. You may photocopy this page. 184 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

"Whether to leave a tip or not” or "Amount


of tip” NE for BP2. Must address both the
percentage and value of tip if asked for.
BOD "type of tip” for BP2

Examiner’s Comments

This question type is new to the J277


specification and asked candidates to list
inputs that will be required as part of the
planning stage for an algorithm. Successful
candidates were able to identify the raw
data needed from the user in order to be
able to solve the problem.

Unsuccessful responses tended to simply


rewrite the question or miss out key
information.

Total 7

© OCR 2024. You may photocopy this page. 185 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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

Most candidates were able to correctly


demonstrate the required steps of the
merge sort algorithm. This involves
merging the set of 8 individual lists into 4
lists of size 2, then 2 lists of size 4, then 1
list of size 8. At each point, each list
produced must be in order. It is this
process of merging lists together that sorts
the values.

No mark was given simply for showing the


final list sorted unless the previous step(s)
had been followed; any candidates an
alternative sorting algorithm (for example a
bubble sort) would achieve 0 marks even
though the final outcome is the same.

Misconception

Many candidates showed merged lists


which were out of order to start with, and
then sorted these merged lists. This is
highly inefficient and not what the standard
merge sort algorithm describes.

In merge sort, the process of merging lists


together produces the sorted list. There
does not need be any second step to sort
values as they should already be in order.
Exemplar 2

© OCR 2024. You may photocopy this page. 186 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

This exemplar shows the misconception


detailed previously. Here, the candidate
firstly merges together the individual lists
into 4 lists of size 2, but these lists are not
all in order (e.g. 17, –27 is incorrect).

The second step then merges these lists


together into 2 lists of size 4, but again,
these are not in order. An unnecessary
next step is then shown where the lists are
then sorted in place.

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

This question asks candidates to describe


how a binary search would look for a
number in a sorted list. Most candidates
answered this well. The most common

© OCR 2024. You may photocopy this page. 187 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

mark for this question was 3 out of 4.

The majority of candidates clearly


understood that the middle value is chosen
and compared against the value being
searched for. However, almost all
candidates then went on to discuss which
half of the list should be discarded or
focused on based on this comparison.

One possibility is that the middle value is


the number we are searching for. Few
candidates discussed this possibility. As
the process repeats, this check is
important if the number is ever to be found!

Assessment for learning

When discussing a binary search there are


three possibilities when comparing the
middle value to the number being searched
for.:
1 the middle value is higher than needed
(in which case the left half of the list
should be focused on)
2. the middle value is lower than needed
(in which case the right half of the list
should be focused on)
3. the middle value is equal to the value
needed (in which case the value has
been found and the process can stop.

Most responses only considered the first


two of these possibilities. This is worth
discussing when teaching this topic.

© OCR 2024. You may photocopy this page. 188 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

c 1 mark each 2 2nd bullet point must cover both ideas of


(AO1 1b) checking all of the values AND being done
Starting with the first value in order.
checking all values in order
“Checks each value” / “one by one” / “step
by step” by itself is NE, does not say in
order.

Do not accept “repeat until value found” for


BP2 (question says number is not in the
list)

“Checks each value from beginning to end”


implies order so gets both BP1 and BP2.

Examiner’s Comments

Responses to this question generally


lacked precision.

The question specifically asks about


searching for a number that is not in the
list. However, many candidates discussed
stopping when the value had been found.
This is clearly not possible given the
scenario.

Many responses discussed checking each


number but did not state whether this
would be in a particular order. Some
candidates discussed checking values
randomly, or even from the right down to
the left.

For this questions, candidates may have


known that a linear search starts at the left
most number and then checks each value
in the list in order until reaching the end of
the list. However, few responses stated
this or anything close to this.

This level of precision (and conversely, not


assuming that steps are obvious) should
be encouraged within GCSE Computer
Science.

Total 9

© OCR 2024. You may photocopy this page. 189 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

30 input and stores/uses value with 6 e.g.


message (AO3 2b)
attempt at repeating… (AO3 2c) num = input(”Enter how many
… correctly repeats number of times numbers”)
given as input
… correctly take number as input for x = 1 to num
within loop and calculates total of these
numbers temp = input(”Enter a
… correctly calculate an average number”)
(total/num)
Output both total and average total = total + temp

next x

print(total)

print(total / num)

If flow chart used, correct shapes needed.

Allow tolerance of 1 with number of loops


for BP3 with for loops

BP1 requires input with a message (can be


two statements, e.g. print and then input or
combined. Input must be stored or used.

BP3, 4, 5 must be logically correct to be


credited Ignore non-initialisation of total

BP 5 can be given as FT as long as an


attempt has been made at working out a
total within the loop.

BP6 can be given as FT long as attempt


made at total and average (not necessarily
in a loop)

Examiner’s Comments

As this question appeared in Section A,


candidates are free to respond in any
suitable way, including using flowcharts,
structured English, pseudocode or a high-
level language. The majority of candidates
who scored highly tended to use a high-
level language consistently.

The question is already decomposed for

© OCR 2024. You may photocopy this page. 190 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

candidates and many were able to use


these bullet points to build a solution that
achieved the majority (or all) marks
available.

Where mistakes were made, these tended


to be with repeating code. For example,
many candidates repeated the process of
adding values up without repeatedly asking
for a new number (and therefore
continually adding the same number).

Other candidates used condition-controlled


iteration to repeat the process but did not
make sure that the condition being
evaluated ever returned a False value,
therefore repeating infinitely.

Where a mistake was made in one section


(such as with iteration), examiners were
instructed to use FT (follow through) marks
where possible if later sections were
logically constructed. This made sure that
marks could be given where appropriate.

A few candidates were not able to access


many of the marks available in this
question, suggesting that they would
benefit from more practical programming
time in lessons.

Total 6

© OCR 2024. You may photocopy this page. 191 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

Example above shows checking for invalid


data. Checks for valid data equally
acceptable Examples shown below:

if firstname != “” and surname


!= “”
if room == “basic” or room ==
“premium”

© OCR 2024. You may photocopy this page. 192 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

if nights >= 1 and nights <= 5

Examiner’s Comments

This question stretched the understanding


of even highly-achieving candidates and it
was not uncommon to see low scoring
responses.

Misunderstanding of Boolean operators


(AND and OR) within selection (IF)
statements was something that affected a
lot of candidate responses.

As this question was in Section B,


candidates needed to respond in OCR
Exam Reference Language or a high-level
language. Responses must be logically
correct to gain the marks. As each check is
two individual checks that both need to
pass, responses can quickly get relatively
complicated.

As can be seen from the mark scheme,


advice and examples were given to
examiners to make sure that candidates
who were able to successfully navigate this
logic chain were credited.
Misconception

Checking whether a room is either basic or


premium can be done in multiple ways.
Candidates can either check for the
positive (i.e. check that it is either basic or
premium) or check that for the negative
(i.e. check whether it is something else).
However, there are many common errors
that were seen :

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

Question Answer/Indicative content Marks Guidance

premium is incorrect as the lack of


string delimiters means that basic and
room would be treated as variables
rather than strings.
IF room != “basic” or room !=
“premium” is also incorrect. This
checks for invalid input but because or
is used, only one condition needs to be
True for the whole statement to be
True. This means that if basic is
entered, it would be classed as invalid
(as it isn’t premium) and vice-versa.
There is no way for any entry in this
example to be classes as valid.
IF room != “basic” and room
!= “premium” is correct. This
checks for invalid inputs but needs
both conditions to be True.

The same explanation follows for the other


two necessary checks.

Exemplar 3

This exemplar shows a fully correct


response. The candidate checks for invalid
responses and correctly uses Boolean
operators to check multiple criteria at each
step. If any check returns True, “Not
allowed” is printed and the program ends.
Efficient use of if … else … means that
the next check only proceeds if the
previous check returns False.

If all three checks return False, the final

© OCR 2024. You may photocopy this page. 194 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

else is triggered to print “Allowed”.

It must be noted that this is only one way of


achieving full marks. An equivalent
program that checks for valid responses at
each turn would also be possible.
Candidates should be encouraged to use
whatever structure they feel is sensible. If a
response can logically be followed then it
will achieve high marks.

ii Normal 3 Allow other descriptions that mean normal


1 or 5 (not 0 or 6 as says allowed) (AO3 2c) (e.g. valid / typical / acceptable)
Any numeric value except 1 to 5 // any
non-numeric input (e.g. "bananas”) Test data Type of test Expected
(number of
nights) output
2 Normal ALLOWED
1 // 5 Boundary ALLOWED
e.g. 7 Erroneous/In NOT
valid ALLOWED
Examiner’s Comments

This question was answered well by the


majority of candidates.

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.

Ignore additional parameters. Ignore inputs


or additional code as long as these do not
overwrite parameters or affect operation of
function.

If inputs used instead of parameters, FT for


BP3. Allow use of else for second room
type in BP3.

Attempt at calculation needed to award


BP4. Must return (not output) value. Return
can be done e.g. in VB by assigning to
function name (e.g. newPrice = price)

e.g.

© OCR 2024. You may photocopy this page. 195 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

function newPrice(nights,
room)

if room == “basic” then

if room== 60 * nights then

elseif room == “premium”


then

price = 80 * nights

endif

return price

endfunction

Examiner’s Comments

Defining functions appeared to be a


concept that candidates did not fully
understand.

Where a candidate did not attempt to


define a function and instead simply
calculated the price needed, very few (if
any) marks were available.

Successful responses could have been


constructed from any suitable function
definition keyword such as function
(OCR ERL, VB, JavaScript, etc), def
(Python) or others. Answers in C#, Java or
other languages referring to methods were
also accepted.

© OCR 2024. You may photocopy this page. 196 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

ii Call function newPrice… 3 Order of parameters not important


…with (“premium”, 5) as (AO3 2b)
parameters “premium” must use string delimiters (e.g.
… Output returned value “quotes”)

e.g.

print(newPrice(“premium”, 5))

x = newPrice(5, “premium”)

print(x)

Do not allow function definitions for BP1

Ignore capitalisation of newPrice

Candidate could store returned value in a


variable and then print this, or store
parameters in variables before passing in -
these are all acceptable

Ignore any superfluous code given

Do not credit answers where newPrice is


overwritten prior to use.

Ignore spaces. Allow function call if


brackets missing (e.g. newprice instead
of newprice() )

Examiner’s Comments

Even if candidates were not able to create


a function, this question was independent
to (i) and so marks were available for
simply using the function to output a value.

Candidate found this question challenging.


Many candidates called the function but
most did not understand that the room type
was a string and so required string
delimiters (e.g. quotation marks) around
the parameter.

Where candidates defined local variables,


assigned the values needed to the
variables and then passed these into the
function call were accepted.

© OCR 2024. You may photocopy this page. 197 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

c For loop changed to include 0 2 Allow loop changed to 0 to 8 or 0 to 9


total = 0 moved to before loop starts / (AO3 2c) (Python)
removed
Do not accept moving total outside loop,
NE (could be moved to after loop which
would still be a logic error). Do not accept
move to top of loop.

Accept corrected code shown.

Accept reference to count variable limits for


BP1.

Examiner’s Comments

This question acted as an excellent


discriminator. The majority of candidates
identified and fixed the problem with the
array (starting at 0 rather than the 1 given).
Fewer candidates were able to identify and
fix the issue relating to the total being set
to zero for each iteration.

A number of candidates identified this


second issue but were either not precise
enough with their response (suggesting
that the line could be moved but not stating
where it should be moved to) or did not
attempt to go beyond the simple
identification.

Candidates should be clear that this


question required detail of how the
program could be refined to fix problems,
not just to identify problem(s).

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

Question Answer/Indicative content Marks Guidance

Initial input outside of loop that is then also


included within loop is fine. For example,
input of hours outside of loop but input is
then repeated again at end of loop.

Do not accept while hours > 0 (could


be -1)

Do not penalise answers where 0 is output


when loop exits

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

This question was relatively well answered


by candidates.

Candidates were generally able to create


suitable high-level program code to
calculate and output the total price based
on the information given.

Many candidates ignored the requirement


to repeat until 0 was entered; in this case,
4 out of the 6 marks were still available.

To achieve marks for iteration it needed to


both repeat the correct parts of the
program and correctly terminate as per the
requirements given.

A typical mistake was to repeatedly


calculate the price but not ask afresh for
new inputs.

© OCR 2024. You may photocopy this page. 199 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Total 23

© OCR 2024. You may photocopy this page. 200 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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

b total = num1 + num2 1 Allow other logically valid responses that


(AO3 2b) result in total storing the correct value.
Accept other suitable assignment
operators (e.g. ← )

e.g.
total = sum(num1, num2)

total = num2 + num1

x = num1 + num2
total = x

Ignore any values given to the variable.


Ignore capitalisation and minor misspelling.
Ignore superfluous code that does not
affect outcome.

Examiner’s Comments

Candidates appear to be getting more


confident at answering simple
programming/pseudocode questions such
as this. The majority of responses included
code written to produce the required
outcome. The use of multiple steps was
allowed.

© OCR 2024. You may photocopy this page. 201 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

c i print(12 ^ 2) 1 Accept ** or other sensible operator that


(AO2 1a) indicates raising to a power.

If pseudocode operator given, must be a


single word/symbol (e.g. pow), not
containing spaces.

ii if number MOD 2 == 0 then 1 Accept % or other sensible operator that


(AO2 1a) indicates modulus

If pseudocode operator given, must be a


single word/symbol (e.g. modulo), not
containing spaces.

iii difference = measurement1 - 1 Accept other sensible operator that


measurement2 (AO2 1a) indicates subtraction.

If a pseudocode operator given, must be a


single word/symbol (e.g. minus), not
containing spaces.

© OCR 2024. You may photocopy this page. 202 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

d 1 mark each: 3 Ignore lines 02 and 05 in answer unless


(AO3 2c) these change or output any values.
Start is set to 3 on line 01 and 3 is
output on line 03. Candidate may repeat start value when
2, 1 and 0 are output on next 3 unchanged, this is acceptable.
iterations with start updated to 2, 1, 0,
-1 on correct line numbers. Penalise incorrect or missing line numbers
Finished is output on line 06 or additional output once only then FT.
This includes where variable change and
output appear on the same line.

-1 must not be output for BP2

Penalise missing or incorrect output once


only for BP1 and FT for missing or
incorrect output for BP2.

Finished may be with or without quotes.


Ignore case or minor spelling error.

Max 2 marks if any incorrect output or


changes to start.

Do not accept calculated values of start


(e.g. 3–1)

Examiner’s Comments

This question assessed candidates’ ability


to trace through and understand the steps
taken by an algorithm. This also tested
their understanding of condition-controlled
loops. Many responses were very
successful with this and achieved full
marks.

Mistakes tended to be with identifying the


line number where each change occurred
or outputting values that were not actually
output (e.g. -1).

Examiners were instructed to only penalise


a misunderstanding once. Where (for
example) line numbers were incorrect, this
would still have allowed 2 out of 3 marks to
be achieved.

Total 11

© OCR 2024. You may photocopy this page. 203 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

33 a 1 mark each 2 Do not allow answers that clearly refer


(AO2 1b) storing the position / index (or any other
stores/holds out of context data) for BP1; it is the name
data/value/name/names[pos] itself that is being stored, not the position.
…so (value) can be changed / If unclear, allow BOD.
swapped / moved / overwritten /
inserted e.g. do not allow “holds the values of the
…without being lost. index / holds value for position of the
will be assigned to names[pos-1] name”.

Allow FT for subsequent points.

Examiner’s Comments

This question was an excellent


discriminator in terms of candidate
achievement. Many responses correctly
described the temp variable as storing the
name so that it could be overwritten during
the process of swapping values. Partial
credit was given for responses simply
commenting on it storing data, as this is
essentially the purpose of any variable.

However, credit was not given where


candidates discussed storing a
position/index, as this was not the case;
the pos variable is used as the index of the
array. The content of this array index (a
name) is stored in the temp variable.

Where responses are open to


interpretation, the mark scheme attempts
to credit as many of these as possible.
However, incorrect responses (such as
reference to the position here instead of
the name) are not credited.

b 1 mark 2 Max 1 from each section, 2 marks total.


(AO2 1b)
do not know how many iterations / Do not allow “while names are in the wrong
swaps needed order”.
do not know (at run time) how many
times the value will change positions BP4 must have reference to checking a
do not know how many times a condition / condition being met, not just
condition-controlled loop will need to having a condition.
run / execute
Examiner’s Comments
1 mark
Previous questions such as Question 2(a)

© OCR 2024. You may photocopy this page. 204 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

condition controlled loops run assessed knowledge (AO1). This question


while/until a condition is true / is false / focused on the application (AO2) of a
until a condition is met technique (condition-controlled loops) to
repeats while value in [pos-1] is larger the algorithm given (an insertion sort). This
than value in [pos] // while (further) assessed candidates’ understanding of the
swap needed process an insertion sort follows to sort
will swap value until in correct position values.
// will swap whilst in incorrect position
More efficient than / does not need to The J277 specification is clear that
iterate as many times as count candidates do not have to remember the
controlled / for loop code for this algorithm. But the
specification does state that candidates
must be able to understand the main steps
of the algorithm and identify the algorithm if
given the code for it. In this case,
candidates were given all of the code for
the algorithm.

Candidates generally found this question


challenging. Many responses simply
repeated the question and discussed
sorting values. More successful responses
understood that the inner loop is the part of
the algorithm that moves the name
repeatedly in the list and that we do not
know how many times this move needs to
be made. Further to this, it is the condition
that the name is in the correct position (or
even better, an explanation of how this is
decided on) which ends the loop.

Assessment for learning

When asked to explain why a particular


technique is used, it is often useful for
candidates to think about why alternative
options have not been used. In this
question, thinking about what would
happen if a count-controlled loop had been
used as the inner loop may have given
candidates the insight to discuss why a
condition-controlled loop has been used.

© OCR 2024. You may photocopy this page. 205 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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

Question Answer/Indicative content Marks Guidance

ii 1 mark each to max 2 2 Allow reference to both sorting / putting


e.g. (AO1 1b) items into order for BP1.

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.

As such, many combinations of answers


could gain the marks available.

Total 8

© OCR 2024. You may photocopy this page. 207 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

34 1 mark each to max 6 6 No need to cast data to string/integer.


(AO3 2b)
Initialise / declare score (to zero) If random numbers chosen, BP3 must use
before use, outside of any loop these. If no random numbers chosen, allow
Generates 2 random numbers between manually setting values
1 and 10
Inputs answer from user displaying BP6 can be awarded for either a loop
suitable numbers repeating 3 times or the same code written
Checks if input is correct answer… out 3 times
… if correct adds 1 to score
Repeats BP2 to 5 three times (for BP5 can be given FT if sensible attempt at
bullet points attempted) BP4
Outputs score after reasonable
attempt at counting Do not award BP6 if same numbers used
for every question. Must pick new values
each time.

Do not penalise potential off by 1 errors for


looping (Python) or random number
generation

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

As this question appears in Section A,


candidates are free to respond in any
suitable way, including using flowcharts,
structured English, pseudocode or a high-
level language.

The majority of high scoring responses


used a high-level language consistently.

Where flowcharts or structured English


were used, responses needed to clearly
show the steps to be taken and not simply

© OCR 2024. You may photocopy this page. 208 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

repeat the question to achieve marks.

The given question is already decomposed


for candidates and many were able to use
these bullet points to build a solution that
achieved the majority of marks available.

Many responses used random number


generation and iteration to create an
elegant response that met all mark points.
This was pleasing to see and it is
extremely encouraging that candidates can
use techniques such as these where
appropriate without being prompted.

Other responses manually repeated asking


the required questions; on this occasion,
these were also credited and could have
achieved full marks.

Where a mistake was made in one section


(such as with iteration), examiners were
instructed to use FT (follow through) where
possible. This allowed candidates to score
marks in later sections if their responses
were logically constructed. This is to be fair
to candidates so that mistakes are only
penalised once in any given question.

A significant number of responses did not


access many marks in this question. This
would suggest that more practical
programming time in lessons would be
beneficial.

Total 6

35 a Allows multiple items of data to be 2 1 mark for each bullet to a maximum of 2.


stored …
under one identifier / name
Can store a table structure
Reduces need for multiple variables

b i Integer 1 Any data type that stores a whole number


only

ii It is a whole number / no decimals / to the 1


nearest minute.

Total 4

© OCR 2024. You may photocopy this page. 209 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

36 a radius 2
area

b i 3.142 1 Maximum of 1 mark


2
1
30

ii The number does not need to be 1 Maximum of 1 mark


changed while the program is running
The number can be updated once and
it updates throughout 1 (A01 1a)
Maximum of 1 mark

Total 4

© OCR 2024. You may photocopy this page. 210 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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

Defensive design is listed in the


specification under section 2.3 ‘Producing
robust programs’.

It is the deliberate act of anticipating how


users could misuse a system, either

© OCR 2024. You may photocopy this page. 211 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

unintentionally or maliciously and then


attempting to reduce these opportunities.

Examples of defensive design in Computer


Science include authentication (e.g. by
asking for a username and password
before allowing access to a system and
input sanitisation (removing unexpected
characters from user input).

Total 4

38 9 1 Correct answer only


AO1 1b Do not accept 32 or 3 x 3
(1)
Examiner’s Comments

Exponentiation is covered in the


specification in section 2.4, Computational
logic under the subheading ‘applying
computing-related mathematics’.

Approximately half of all candidates did not


understand the use of this symbol, even
when the meaning was given in the
question.

The most common incorrect answer was to


treat exponentiation as synonymous to
multiplication.

Total 1

© OCR 2024. You may photocopy this page. 212 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

39 a 1 mark for naming the example and 1 mark 4


for an example related to that method (AO2 1b)

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. π

b radius 2 1 mark per bullet up to a maximum of 2


area (AO1 1b) marks.

c i 3.142 1 1 mark for one correct identification.


2 (AO2 1a)
1
30

ii The number does not need to be 1 Maximum of 1 mark.


changed while the program is running (AO1 1a)
The number can be updated once and
it updates throughout

d HAS been used 3


HAS been used (AO2 1b)
HAS NOT been used

Total 11

© OCR 2024. You may photocopy this page. 213 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

40 a Integer (1)… 1 One mark for appropriate data type


(AO3 2a) identified.
…number of seconds not important (1) 1
… level of accuracy not needed so (AO3 1) One mark for appropriate justification
round to nearest minute (1) linked to the data type chosen.
…using a decimal to store seconds
(0-60) is not appropriate (1)

Real (1)…

… number of seconds may be


important (1)
… allows parts/fractions to be stored
over integers (1)

b print (minsPlayed[0,4]) 1 High-level programming language / OCR


(AO3 2b) Exam Reference Language response
required

Do not accept pseudocode / natural


English.

print may be a suitable output command


word that could be found in a HLL e.g.
print (Python), console.writeline
(VB), cout (C++)

The array elements may be accessed


together [0,4] (VB.NET) or separately
[0][4] (Python)

Total 3

41 freeseats called with "Red" 2 redseats = freeseats("Red")


…returned value assigned to variable
redseats “Red” must use suitable string delimiters
(e.g. speech marks) if directly passing the
string. Do not penalise case.

Total 2

© OCR 2024. You may photocopy this page. 214 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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

b i One mark per bullet point, in the correct 5 e.g.


place
function checkdiscount(price,
size // len(discountcodes-1) code)
code newprice = price
price // newprice size = len(discount)-1
[x,1] // [x][1] for x = 0 to size
return newprice // if discount[x,0] == code
checkdiscount = newprice then
newprice = price –
discount[x,1]
endif
next
return newprice
endfunction

ii One mark per bullet point, maximum 2 2 Do not penalise capitalisation


marks
Accept price, code, discount
newprice
size
x

© OCR 2024. You may photocopy this page. 215 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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

43 SELECT StudentName, Subject, 1 Correct Answer Only


Grade (AO1 1b)
FROM Results 2 Accept SELECT *
WHERE Subject = "Art" (AO3 2a)

Total 3

© OCR 2024. You may photocopy this page. 216 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

44 i timer = 7.3 1 Ignore dim / define / etc and data types


Do not allow use of string delimiters or
AO3 other unsuitable data types.
2b(1) Allow other suitable assignment symbols
(e.g. := ) Do not allow == for assignment.
Do not penalise case. Spelling must be
accurate

ii Real // Float 1 Allow decimal, single, double or equivalent

AO2
1b(1)

Total 2

45 Line Program code output 4 Examiner’s Comments


08 print (score) 18 Question (a) gave candidates pseudocode
AO2 (including a function) and were asked to
09 print ("name") name 1b(4) state the output values from various lines.
10 print (newscore 37 Most candidates were able to do this for
(score,2)) more simple output. Fewer candidates
completed the function call and return
11 print (score) 18
values accurately.

Many candidates struggled to differentiate


between name (as an identifier for a
variable) and “name” (as a string).

Misconception

print(“name”) will output the literal


string “name” to the screen”.

print(name) will print the contents of the


variable with identifier name.

Total 4

© OCR 2024. You may photocopy this page. 217 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

46 a SELECT ItemCode // * 4 Accept other fields shown in addition to


FROM ITEMS ItemCode
WHERE AO3
…Stock < 10 2b(4) Accept Stock <=9 / etc.

Ignore case. Spelling of fields and table


must be correct.

If WHERE missing, Stock < 10 must be


after FROM clause.

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

Page 43 of the specification lists the SQL


keywords that should be covered. These
are limited to SELECT, FROM, WHERE,
LIKE, AND, OR and wildcards.

The current specification is available here :


https://www.ocr.org.uk/images/225975-spe
cification-accredited-gcse-computer-
science-j276.pdf

b 1 mark per bullet 5 Accept alternative error messages.


Variable names must not include obvious
Input from user AO3 spaces.
Check IF input value is “on”… 2b(5)
… if so, assign 1 to statevalue BP3 dependent on BP2. BP2 and BP4
Correct assignment of 2 for “off” and 3 must be a logical comparison using IF and
for “suspended” with correct state and not just the CASE statement. NE to simply
IF replace CASE with IF.
Correct logical check (else) to output
“invalid state” if no state set Penalise each error once then apply FT.

e.g.
newstate = input("Enter the new state : ")

if newstate == "on" then

statevalue = 1

© OCR 2024. You may photocopy this page. 218 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance


elseif newstate = "off" then

statevalue = 2

elseif newstate = "suspended"

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

Appendix 5f of the GCSE Computer


Science specification covers the
pseudocode guide for this examination.
Candidates do not need to use this in their
responses but they should be aware of this
as questions will be presented using this
format.

The current specification is available here :


https://www.ocr.org.uk/images/225975-spe
cification-accredited-gcse-computer-
science-j276.pdf

Total 9

© OCR 2024. You may photocopy this page. 219 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

47 i 3 1 CAO

AO1
1b(1)

ii 1 1 CAO

AO1
1b(1)

Total 2

48 1 mark for each completed statement 6 Allow singular/plural, ignore case/spelling


function calculate(measurement,
number)
if measurement = "gigabytes"
then
value = number * 1024 *
1024 * 1024 * 8
elseif measurement =
"megabytes" then
value = number * 1024 *
1024 * 8
elseif measurement =
"kilobytes" then
value = number * 1024 * 8
elseif measure = "bytes" then
value = number * 8
else
return -1 // value = -1
endif
return value
endfunction

Total 6

© OCR 2024. You may photocopy this page. 220 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

49 a Initialises (total) as 0 (outside loop if 6 Example answer total = 0


present) while total <=100
Inputs a number and stores the value x = input(“Enter a number”)
Adds the input to the total (initialised in total = total + x
BP1 if present) print(total)
Prints the total endwhile
Iterates over BP2-4 (if present)⋯
⋯until total is over 100 Examiner’s Comments

This part required candidates to implement


an algorithm. The algorithm takes a
numerical input, adds it to a total and
repeats this until the total is over 100.

Most candidates were comfortable with


basic input and output of values. Many
candidates were able to attempt to
implement a loop. Fewer candidates were
familiar with how to continually add to a
total.

A number of candidates did not appear to


appreciate that while print(total + x)
may display the sum of the two variables, it
does not add the values together and then
store them.

Misconception

print(total + x) will output the sum


of the two variables without changing
either. Instead total = total + x (or
in some languages, total += x ) will
modify the variable total, which can then be
printed if needed.

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

Question Answer/Indicative content Marks Guidance

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

Ignore superfluous instructions as long as


they do not affect the outcome of the
algorithm.

BOD misspelling of Count as long as it is


recognisable
Ignore capitalisation.

Examiner’s Comments

This question asked candidates to


complete a flowchart for an experiment.
Many candidates were able to gain some
marks for:

• initialising the 'Count' variable


• outputting this at the end
• repeating if 10 values had not been
asked.

Some candidates did not complete the


flowchart. They did not successfully join
the elements together correctly from top to
bottom.

© OCR 2024. You may photocopy this page. 222 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Only high achieving candidates were able


to correctly decide where the NO output
from the first decision box should lead to.
The correct response was to skip over the
increment but then complete the second
decision.

AfL

The use of flowcharts to communicate


algorithms should be taught as an
alternative to pseudocode and students
assessed on the logical flow expressed in
these.

ii 1 mark per bullet point, max 5 5 Example answer


count = 0
Initialises a count variable to 0 for x = 1 to 10
asks user for an input value = input(“enter a
Check if input is over 50⋯ value”)
⋯ increment count variable if True if value > 50 then
Repeats BP 2 and 3 (if present) until count = count + 1
10 numbers have been entered endif
Outputs count once 10 numbers have next x
been entered print(count)

Response must be in pseudocode as per


question, flowcharts or structured English
are NAQ.

Examiner’s Comments
This question utilised similar understanding
to this part, but utilised the loop in a
different way.

This time, the algorithm was required to


repeat a set number of times and so a
count-controlled loop would be most
appropriate. Many candidates did this
successfully and were credited for their
answers.

Where candidates used condition-


controlled loops or other methods (such as
recursive calls to a function), these were
also credited as long as they were logically
correct.

© OCR 2024. You may photocopy this page. 223 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

The loop had to repeat 10 times to be


correct. Benefit of doubt is given where
languages such as Python are used, where
defining this precisely could be ambiguous.

A small number of candidates attempted to


write out the algorithm ten times which did
not meet the requirements of the question.

AfL

Centres should be encouraged to teach


about iteration using both count-controlled
and condition-controlled loops, comparing
and contrasting the use of these for various
situations. Rewriting a count-controlled
loop to use a condition instead (and
therefore manually incrementing the
counter variable) is a relevant challenge for
students.

Total 20

© OCR 2024. You may photocopy this page. 224 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

50 a Contents of variable can be changed; 1 Both sides needed for mark.


contents of constants cannot be
changed (while the programming is
running)

b i 16 1

ii 2 1

iii 9 1

c i second.substring(3,5) 1 Ignore print / lack of print. Allow other


suitable methods of string manipulation as
long as variables used.

Allow any valid method that extracts


rightmost 5 or 6 characters of second
variable.

ii first.substring(0,8) 1 Ignore print / lack of print. Allow other


suitable methods of string manipulation as
long as variables used.

Allow any valid method that extracts


leftmost 8 or 9 characters of first
variable.

© OCR 2024. You may photocopy this page. 225 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

iii first.substring(9,7) + “ ” + second 1 Ignore print / lack of print. Allow other


“Science ” + second suitable methods of string manipulation as
first.substring(9,7) + “ is great” long as variables(s) used.

Allow alternative concatenation symbols


(e.g. & or .). Allow concatenation functions

Must have correct spacing in outcome.

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.

Candidates are able to use any valid string


manipulation techniques from any relevant
high-level language or any sensible
pseudocode. For example, where the
variable second contains the string “is
great”, the output “great” could be
produced with right(second, 5) ,
second[3:], or any other sensible
manipulation.

Examiners attempted to be very generous


with their marking of this question.
However, candidates generally appeared
to be unfamiliar with substring operations.

Misconception

String manipulation can join together


(concatenate) strings using the + sign.
However, the – sign cannot be used to
remove values from strings; it would not be
appropriate to expect that is great –
is would give “great”.

Total 7

© OCR 2024. You may photocopy this page. 226 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

b Returns a value // passes back a value 1

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

ii Use selection / IF / Switch-Case / 3 Allow equivalent checks (e.g. <5, between


range check 0 and 4) for BP2
⋯check that parameters are >=0 and Allow reference to r and c as parameters.
<= 4⋯ BOD handle error for BP3 (e.g. repeat until
⋯Return error code if invalid // set valid)
outcome to error Answer must be a description, code by
itself is NAQ

d Input two position values separately 6 If flowchart / structured English, do not


calls checkblock() function⋯ allow simple repeat of question.
⋯with input parameters Example answer
⋯ returned value used in selection loop = True
If free, stores “A” to correct index of while loop
gamegrid array (FT for incorrect row = input(“enter row”)
selection) col = input(“enter column”)
Loops until free position chosen if checkblock(row,col) ==
“FREE” then
gamegrid[row,col] = “A”
loop = False
endif
endwhile

Total 14

© OCR 2024. You may photocopy this page. 227 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

52 1 mark per correct row 4 No mark given if both boxes in a row


(AO2 1b) ticked.

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

Question Answer/Indicative content Marks Guidance

53 i Convert/change one data type to 2 Do not accept "change to string” - this is


another (AO1 1b) the use in this example but not a definition.
Line 03 // 3 // three (AO2 2b)
Examiner’s Comments

Many candidates correctly defined casting


as changing data from one data type to
another. Some candidates defined this
term as changing a variable from an
integer to a string, which is only one
example of what can be done and not a
definition.

The majority of candidates then gave the


correct line number (line 03) for there this
was shown the example code given.

ii Kofi2021 as staffID on line 03 4 Max 2 if incorrect order. Ignore misspelling


Kofi2021x as staffID on line 05 (AO3 2c) of Kofi
Kofi2021xx as staffID on line 05
ID Kofi2021xx output on line 07 as first Penalise lack of / errors with line numbers
and only output once then FT. Ignore capitalisation. Ignore
additional lines unless outcome impacted.

staffID does not have space in. Output


does have a space in. Penalise spaces
once then FT. Do not penalise unless
obvious.

Quotes around answer is OK, but do not


allow quotes around partial answers, e.g.
“ID” Kofi2021xx is incorrect.

Line surn year staf Output


num ame fID
ber
01 Kofi
02 2021
03 Kofi2
021
05 Kofi2
021x
05 Kofi2
021x
x
07 ID
Kofi2021xx

© OCR 2024. You may photocopy this page. 229 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Examiner’s Comments

This question asked candidates to trace


through a given algorithm to show the
value of three variables at various points in
the algorithm.

The algorithm itself was relatively simple. It


used condition-controlled iteration to repeat
while the length of the username was less
than 10 characters.

Most candidates gained the first 2 marks


for the initial changes to staffID.
However few candidates were able to trace
through the iteration and conclude that the
final username should end up as ID
Kofi2021xx.

Marking this question considered the


spaces within the username at various
points. The algorithm results in one space
only, in between ID and Kofi2021xx. Where
extra spaces appeared or were missed,
this was penalised. However, examiners
were instructed to give clear benefit of
doubt, and to only do this if the space was
clearly present/missing.

It is important to understand that “ab” and


“a b” are two strings that are not the same.
This level of precision should be
encouraged within GCSE Computer
Science. Experience of practical
programming will help reinforce the impact
of spaces within programming and
algorithms.

Total 6

© OCR 2024. You may photocopy this page. 230 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

54 i Multiplication 2 Accept other correct answers that mean


Division (AO1 1a) the same Accept floor / integer division //
division with no remainder (Python v2.x)

Examiner’s Comments

This question was answered well by the


majority of candidates.

ii high-level 5 Ignore spelling errors.


stops // crashes (AO1 1b)
no (AO2 1b) Examiner’s Comments
executable
without This question was answered well by the
majority of candidates.

Total 7

© OCR 2024. You may photocopy this page. 231 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

55 i Integer 2 Accept other valid data types from high-


String (AO3 2a) level languages (e.g. byte, short for
integers)

Do not accept descriptions (e.g. “whole


number”, “text”). Do not accept
“character(s)” for string.

ii stayComplete 1 Ignore spaces or misspelling as long as


(AO3 2a) recognisable.

Examiner’s Comments

These questions tested candidates’


knowledge of data types and it was clear
that this knowledge was well understood.
The majority of candidates were able to
correctly identify suitable data types in
section (i) and identify stayComplete as
the field that would be stored as a Boolean
data type.

© OCR 2024. You may photocopy this page. 232 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

Allow other logically valid SQL statements.


Check with TL if required.

Ignore reference to stayComplete or


other valid SQL code that would not affect
output.

Max 3 if in wrong order or if includes any


extra invalid code

Examiner’s Comments

This question tested candidates’ ability to


refine and rewrite incorrect code given to
them. It is important to note that although
the SQL statement as a whole is incorrect,
not all components are incorrect; in this
case, the FROM clause is correct and
candidates who made no change to this
line were credited.

SELECT ALL is invalid SQL and should


have been written to instead include all
fields from the table, separated by commas
SELECT * was equally accepted as a
suitable response.

IF is not a valid SQL keyword and needs


to be replaced with WHERE. The criteria for
this statement was also incorrect. The
comparison symbol is incorrect and should
read Nights > 1.

Most candidates gained some marks on


this question. The most common response
corrected the criteria and not modifying the
FROM clause.

Total 7

© OCR 2024. You may photocopy this page. 233 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

56 a 1 mark for each row 4 No mark if more than 1 tick on a row.


(AO3 2a)
Allow other indications of choice (e.g.
cross) as long as clear.
Variable Boolea Ch Str Integ Re
n ar ing er al
UserName ✓
EmergencyP ✓
honeNumber
DoorSensor ✓
Active
DoorActive ✓
Time

b 1 mark each: 4 Selection could be done using IF


(AO3 2b) statement, case statement or any other
Attempt at using selection / condition sensible valid method.
controlled loop
Checking if system armed // while Allow reference to AlarmActivated or
system armed equivalent instead of SystemArmed
If Door Sensor active OR Window
Sensor active (both checks required) Ignore any inputs or modification of
calling SoundAlarm correctly variables.

Allow True / False as strings. Allow


checking against strings (e.g. if
SystemArmed == “active”)

Allow checking armed/disarmed for BP2


and BP3

Only award BP4 if SoundAlarm correctly


called / not called in every situation. If
issues on previous lines (e.g. lack of
brackets where needed) means this is not
the case, do not award BP4.

Checking could be done by evaluating


variable directly (if SystemArmed) or by
comparison (if SystemArmed ==
True)

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

Question Answer/Indicative content Marks Guidance


else if WindowSensorActive
then
SoundAlarm()
endif
endif

Example answer 2

while SystemArmed then


if DoorSensorActive then
SoundAlarm()
else if WindowSensorActive
then
SoundAlarm()
endif
endif

Example answer 3

if SystemArmed and
(DoorSensorArmed or
WindowSensor) then
SoundAlarm()
endif

Note – above example needs brackets,

if SystemArmed and
DoorSensorArmed or WindowSensor
then

is not logically valid for this scenario (will


sound alarm when not armed if window
sensor is active)

Example answer 4

if SystemArmed and
DoorSensorArmed
SoundAlarm()
else if SystemArmed and
WindowSensorArmed
SoundAlarm()
endif

Examiner’s Comments

Many responses achieved highly on this


question. The question asks for a simple
program to be written that checks the given

© OCR 2024. You may photocopy this page. 235 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

variables and calls the given procedure


when necessary.

Examiners were instructed to be generous


with the first mark, crediting any use of
selection or condition-controlled iteration.
Responses may therefore have been
rewarded for an attempt at this question
even if their solution was not fully
functional.

Centres should encourage candidates to


attempt each question for precisely this
reason; it is typical that a small number of
marks are allocated to attempting a
solution on many programming questions
for J277/02.

A significant number of responses were


given 3 out of 4 marks as they
misunderstood the role of operator
precedence in their solution; this is detailed
in the "misconception" box below.

Misconception

Where multiple conditions are used in


selection, these have an order of
precedence very much like BIDMAS does
in mathematics; an AND operator will
always take precedence over an OR
operator. A NOT operator (not used in this
question) would have even higher
precedence.

This can cause problems in candidate


responses. A common candidate response
was:

if SystemArmed AND
DoorSensorActive OR
WindowSensorActive then
SoundAlarm()

However, because the AND operator takes


precedence, the first check done here is if

© OCR 2024. You may photocopy this page. 236 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

the system is armed and the door sensor is


active. The result of this is then evaluated
with an OR operator to check if the window
sensor is active.

This results in the alarm sounding if the


window sensor is active, even if the system
is not armed. This was clearly not the
candidate's intention.

To fix this, candidates could have either:

put brackets/parentheses around the


Door OR Window section of their
response
written the response as separate
checks. This could have been done in
multiple ways, including nested if
statements or repeated checks.

Exemplar 1

Exemplar 1 shows one way that full marks


are achieved on this question. The
candidate has used nested if statements
to check if the system is armed, and if true,
then checking if either sensor has been
activated. The SoundAlarm() procedure is
only called if both if statements evaluate to
True.

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

Question Answer/Indicative content Marks Guidance

ii 1 mark from 1 Do not penalise case, spacing or minor


(AO3 1) misspellings.
sensorType
sensorNumber Examiner’s Comments
sensorID
The vast majority of candidates are
confident with identifying variable
identifiers, such as sensorNumber. Small
errors in spelling or spacing were not
penalised. Candidates should be
encouraged to be accurate with their
namings, particularly if these are already
given to them in the question.

© OCR 2024. You may photocopy this page. 238 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

iii 1 mark for 1 Ignore minor misspelling.


(AO3 1)
Boolean Accept Bool.

Examiner’s Comments

Many candidates found this question


challenging. The question relies on
understanding of how selection statements
operate. The answer of Boolean can be
inferred from how the function return value
is used.

This use of Boolean values in selection


statements also caused confusion in the
previous J276 specification. It would be
beneficial for centres to cover this
specifically. More detail is given in the
misconception box below.

Misconception

Where Boolean values are used in


selection, there is no need to compare this
to a True or False value. Line 02 uses an
IF statement based on the return value
from a function CheckSensorCode().
Because the function returns a Boolean
value, the IF statement is valid. Looking at
another example, if the variable x is
Boolean, then both of the following would
be valid:

if x == True then…
if x then…

In both cases, if the value of x is True, the


code underneath would be executed. The
second version (without comparing a
Boolean value to True or False) is more
elegant.
However, both would be accepted as
responses in an examination.

© OCR 2024. You may photocopy this page. 239 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

v 1 mark each 2 Ignore minor spelling errors / differences


(AO3 1)
Selection Do not accept examples (e.g. IF)
Sequence
Examiner’s Comments

The three programming constructs given in


the specification are selection, sequence
and iteration.

Sequence and selection are used within


this program.

There is no use of iteration in the given


program.

Surprisingly for an AO1 question, this


proved relatively challenging for candidates
with many identifying other features of the
code, such as inputs, function calls or
variables.

© OCR 2024. You may photocopy this page. 240 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

d 1 mark each 3 Max 2 if out of order or anything extra that


(AO3 2c) affects the output.

SELECT SensorID // SELECT * BP1 can select multiple fields as long as


FROM events SensorID is included.
WHERE Length > 20 AND
sensorType = “Door” Ignore case. Only penalise spaces if
// obvious.
WHERE sensorType = “Door” AND
Length > 20 Field names must be correct.

“door” must be in quotation marks for BP3.


Allow quotation marks for field names and
table name

BP3 can use == or = for equivalence.

Allow alternative WHERE clauses that are


logically correct (e.g. WHERE length
>=21)

Examiner’s Comments

Structured Query Language is obviously


well understood by many candidates. Many
high-quality responses were produced.

Most responses were able to use SELECT


and FROM appropriately to produce a
logically correct response. However, the
vast majority of responses missed off the
requirement that only door sensors were
required to be included, gaining 2 out of 3
marks in the process.

Although a suggested response is shown


in the mark scheme, any logically correct
SQL that produces the required output
would be accepted by examiners.

Where a mistake was made consistently


(such as using colons after the SQL
keyword), this was penalised once and
then FT (follow through) allowed for
subsequent marks.

© OCR 2024. You may photocopy this page. 241 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

e 1 mark each 6 Must be clear that answer is a procedure


(AO3 2b) definition, do not credit calling procedure
Define procedure SaveLogs… for BP1. Allow function definition.
…with two valid parameters
Open file (for write/append) … If parameters are later overwritten, do not
… using the file name passed in as credit BP2 but FT for BP4 and 6.
parameter
Write data to file… Closing text file does not need reference to
…using the data passed in as file name/object – e.g. “close file” is
parameter enough. However, if given reference must
Close file be correct.

If code given outside of procedure, do not


give BP4 and BP6

Allow FT for multiple occurrences of same


mistake (e.g. not using filename correctly
for open and close)

Example answer

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

Examiner’s Comments

This question proved to be challenging for


many candidates. The question combined
defining a procedure with the use of text
files.

The tasks required were partially


decomposed in the bullet points. A
candidate attempting these in order would
have achieved a significant number of
marks.

Candidates could also have achieved


numerous marks for a partial solution (e.g.
defining a procedure that didn't use text
files or writing to a text file outside of a
procedure) and the mark scheme was
deliberately constructed to credit these
responses.

© OCR 2024. You may photocopy this page. 242 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Full marks were often given where


candidates appear to have had practical
experience of these two techniques.

Exemplar 2

Exemplar 2 shows a response that scored


full marks. The procedure has been
defined with multiple parameters which are
then used to open the file and to write the
data. The candidate has also achieved the
bullet point 7 on the mark scheme (closing
the file) but this wasn’t necessary in this
case.

f i 1 mark for: 1 Accept type casting Do not accept


(AO3 2a) conversion. Do not accept examples of
Casting / cast casting.

Examiner’s Comments

The use of the term "casting" to convert


one data type to another is now well known
and understood by candidates. This is
given and referred to in the J277
specification and is essential knowledge.

© OCR 2024. You may photocopy this page. 243 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

ii 1 mark each to max 6 6 BP2 can be achieved either by iteration


(AO3 2b) accessing each event or manually
Input date and store in variable / use repeating code to access each event. Must
directly be 0 to 6, not 1 to 7.
Access all seven (indexes 0 to 6)
events in array // loop for each event in Allow reference to events (table given)
array or arrayEvents (2D array) in answer as
Attempt at selection… long as used consistently.
…to compare date input against date
in array (element 0) BP2 loop allow off by one errors (Python),
…adding length (element 3) from looping to array length or array length – 1.
array to the total if dates match. Allow for each item in array or any
Outputting calculated total and date in other suitable loop.
appropriate message(s) at the end
BP4 and BP5 allow array reference as
either column major or row major.

Output can either be once at the end or on


every iteration, as long as it is output at the
end.

Only give output mark if attempt made to


calculate total within the algorithm.

Do not penalise capitalisation or minor


misspellings of variable names.

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

Question Answer/Indicative content Marks Guidance


if item[0] == date then
total = total + item[3]
endif
next count
print("There were " + total + "
events on " + date)

Examiner’s Comments

The final question in Section B is expected


to be a high demand question.

The techniques required (iteration through


a 2D array, selection, keeping a running
total of times) are within the specification
but it is acknowledged that the level of
challenge was high.

Examiners were instructed to give marks


for an attempt at a solution (as with
previous questions).

For this question marks were given for:

any attempt at selection


any solution that accessed each
element in the given array, even if this
was via a manual process.

Therefore, many candidates gained


multiple marks for an attempt that only
partially solved the problem.

A significant number of candidates were


able to create a solution that fully met the
requirements of the question. This was
often done in an elegant and efficient
manner.

This is extremely pleasing and shows


excellent understanding and significant
experience of practical programming.

Exemplar 3

© OCR 2024. You may photocopy this page. 245 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Exemplar 3 shows a high scoring


response. A date has been asked for as
input which has then been used to
compare to each element at position 0 in
the array.

Where any of these match, the total


variable is updated to keep a running total
of the corresponding element at position 3
in the array.

After each element has been checked, the


total and date are output in a suitable
message.

This is not the only method by which a


response could be given full marks but is
perhaps the most common.

Total 30

57 Comments / annotation… 6 1 mark for identification of an example from


… To explain the key functions / the programme.
sections 1 mark for explanation of how it aids
… E.g. any relevant example, such as maintainability.
line 4 checks the input is valid 1 mark for contextualisation.
Indentation… Maximum of 3 marks per method.
… To show where constructs / sections
start and finish
…E.g. indenting within IF statement
Using constants…
… so numbers can be updated easily
…E.g. TT

Total 6

© OCR 2024. You may photocopy this page. 246 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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. MP1 must have appropriate identifier, =


total = 0 and then the numeric 0
for x = 0 to 4 MP2 must have for or while
total = total + MP3 must have the for stopping condition
hoursplayed[2, x] 4/5
next x MP4 must have the same identifier for MP1
console.writeline(total) and equal and + to add the data in the
array (using either [x,y] or [x][y]. This
e.g. could be total = total + …. Or
total = 0 total += ….
for x in range (0, 4)
total += hoursplayed[2][x]
next x
print (total)

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

Question Answer/Indicative content Marks Guidance

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

Question Answer/Indicative content Marks Guidance

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

This question asked about maintainability.


It was important that a candidate’s
response referred to the code given.

“Give two ways that maintainability of a


program could be improved” is a different
question than the one asked.

Because of this, responses that were


accepted must genuinely improve the
maintainability of the program shown. One
very common wrong response was
indentation; although this would be useful
generically, there was no code presented
that would benefit from being indented.

Many candidates were able to give


responses such as use of comments and
sensibly named variables that would
genuinely improve the given program.
Where candidates described putting the
given code inside a newly defined
subroutine. This response was credited.
However some responses simply said “use
a subroutine”. This was not enough.

Total 2

© OCR 2024. You may photocopy this page. 249 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

61 a 1 mark each: 2 Question asks for a definition. Examples


Syntax error (AO1 1a) may strengthen the response but are not
acceptable by themselves.
Error in the rules/grammar (of the
program language). Do not allow “error/problem in the code,
Program does not (fully) run / translate does not work / does not do what
/ execute / start (BOD) designed/intended to do” for either, this
applies to both.
Logic error
“Error in the syntax” or “error in the logic”
Produces incorrect / unexpected are NE even with examples
result/output
Program runs/does not crash Examiner’s Comments

This question was answered extremely


well by most candidates. These candidates
correctly defined the terms given.

Candidates must understand that an


example is not the same as a definition.
For example, a misspelling of a command
such as print would of course be a
syntax error but this is not a definition;
many other issues would cause a syntax
error.

Other incorrect responses included generic


responses that could apply to either term,
for example: "a mistake in the program" or
"where the computer doesn't understand
the code".

b Line number 4 1 mark for each line number correctly


(AO3 2c) identified.
02 1 mark for each correction. Correction
must match line number.
Correction
If wrong line number, do not mark
for scoreCount = 0 to correction. If no line number, mark
scores.length - 1 correction only.

Line number Do not penalise if response removes –1


from scores.length as long as it starts
03 at 0.

Correction Do not penalise potential off by 1 errors for


looping (Python).
total = scores[scoreCount] +
total Do not penalise case or minor spelling
total = total + errors as long as intention is clear.

© OCR 2024. You may photocopy this page. 250 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

scores[scoreCount]
total += scores[scoreCount] Allow description of change that would be
made (e.g. “change 1 to 0”)

First correction is fixing indexing error so


element 0 is included. This could be done
on line 03 e.g. scores[scoreCount-1].
Second correction is fixing addition of total.

If both errors fixed on line 03, full marks


should be given. e.g.
total = total +
scores[scoreCount-1]

Examiner’s Comments

This proved to be a relatively challenging


question for many candidates. This
question relied on an understanding of the
term "logic error".

Two errors were present:

line 02 (where the count-controlled


loop ignored element 0 in the array)
line 03 (where the total was incorrectly
calculated and stored).

Many responses identified at least one of


the line numbers containing the error. Far
fewer were able to successfully fix the
errors satisfactorily.

Examiners were instructed to be generous


in interpreting potential fixes. The errors in
either case could have been fixed using
OCR Exam Reference Language (as
presented) or using any other sensible
form. Responses using programming
syntax were credited, as were those who
simply used English, e.g. “change the 1 to
a 0 on line 02”.

Instructions were also included in the mark


scheme to allow full marks for candidates
who fixed the errors in one step on line 03.

Total 6

© OCR 2024. You may photocopy this page. 251 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

62 a i 1 mark each to max 2 2 Allow answers that explain what would


(AO1 1b) happen if not tested (e.g. “there might be
Check the program works (as bugs”)
intended)
meets user requirements. Examiner’s Comments
gives the correct output / result
Find / detect / check for errors / bugs Testing as a process could be done for
Check the program does not crash // is many reasons. The mark scheme attempts
robust // executes / runs to credit as many sensible explanations for
To try and break the program // this as possible. This includes testing to
destructive testing find errors, checking for robustness and
Test for / improve usability / user checking against user requirements.
experience / performance // check user Furthermore, fixing errors that are found is
feedback is suitable also credited as this could form part of the
Allow any errors to be fixed // make testing process.
changes / improvements as a result of
testing The majority of responses demonstrated
Ensure no problems / issues fixed an understanding of this and achieved
when released. highly.
Defensive design considerations /
anticipating misuse / so cannot be
misused

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.

Boundary / Extreme testing… White box testing…


…test using data that is on the edge of …testing with access / knowledge of
being acceptable / unacceptable. system’s workings.
…test highest / lowest value
Allow other sensible / valid types of testing.
Invalid / Erroneous testing…
…test using data that should be Do not accept examples of validation (e.g.

© OCR 2024. You may photocopy this page. 252 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

rejected / is not acceptable / causes an type test, range check)


error
“data that is not expected” is NE for
invalid/erroneous unless clarified.

Examiner’s Comments

The J277 specification lists iterative and


final/terminal testing as test types.
However, many candidates interpreted this
question as asking about test data (such
as normal or erroneous data). Where
candidates described the use of test data
and link it to expected outcomes, this was
credited by examiners.

Other types of suitable testing that do not


appear on the J277 specification (such as
white box/black box testing, alpha/beta
testing) were also accepted.

Assessment for learning

The J277 specification states the minimum


content that candidates are expected to
know and understand at GCSE level.
However, it is possible for teachers to go
beyond this.

For example, iterative and final/terminal


testing are stated in the specification.
However, there are other types of testing.
Other technically correct responses will be
accepted by examiners even if they do not
appear in this specification.

Another example is sorting algorithms.


Merge sort, bubble sort and insertion sort
appear in the specification. However, when
candidates have been asked to name
sorting algorithms, previous mark schemes
credit other valid responses (such as quick
sort, selection sort or bogo sort).

© OCR 2024. You may photocopy this page. 253 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

Error reporting / diagnostics Allow sensible references to AI where


… identify location/detail of errors appropriate. Sensible description of use
…suggests fixes needed.

Debugger … Allow other sensible features of an IDE


…find errors (e.g. line numbering, auto indent, collapsed
blocks, etc) with suitable description.
Stepping …
… execute/run the program line by line For text editor / error diagnostics /
debugger, allow other sensible features
Variable watch… listed as features in the mark scheme as
… see the contents/data held in description (e.g. “text editor, provides
variables pretty printing”, “debugger, provides
stepping”)
Break points …
… will allow the program to stop at a Examiner’s Comments
chosen / set position
This question was generally well answered
Text/code editor… with a variety of features given. The
…allows program code to be written / question specifically asks about features
entered / changed used when testing a program. Therefore,
…allows errors to be fixed features such as debugging tools, stepping
and variable watch windows were very
Pretty printing // keyword highlighting… common responses.
… allows keywords / variables to be
coloured / identified However, more general responses were
also accepted, such as text editors,
Keyword completion // syntax translators, and keyword completion.
suggestion… These could all potentially be used when
…suggests code/syntax when first part editing programs after errors had been
entered. identified.

© OCR 2024. You may photocopy this page. 254 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Less successful responses tended to be


descriptions that simply repeated the name
of the feature given. For example
"debugging tools, to allow debugging"
would gain 1 mark for the feature
identification but not the description.

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).

Type check For length check, must be clear that the


… making sure the data inputted is of string version of the data input is being
the correct data type checked to award use marks (e.g.
… make sure answer / input is an characters not digits).
integer (or equivalent e.g. whole
number) Accept alternative names or descriptions
(e.g. existence check, boundary check) but
Presence check name of check must be sensible.
… making sure a value is inputted / not
blank Mark each answer as a whole, ignore
… reference to answer / input method/use headings.
…by example of program code
Do not accept defensive design elements
Length check (e.g. input sanitisation, authentication)
… limit number of characters // check
maximum / minimum string length Examples of program code can be actual
… answer / input must be 1 or 2 code (e.g. if inp>=2 and inp<=20) or
characters identification of technique (e.g. “use IF
…by example of program code statement / Case statement to limit values
to between 1 and 20”). Do not accept code
Format check just showing casting.
… making sure the data inputted
follows a set pattern Examiner’s Comments
… checking answer / input consists of
only 1 or 2 numeric digits Responses which focused on the explicit
…by example of program code link to the game described in this question
tended to do well.
Look up / table check

© OCR 2024. You may photocopy this page. 255 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

… 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.

Some candidates gave examples of


validation which did not clearly link to the
game. Generic examples were partially
credited. Explicit links to the game were
required in order to gain all marks
available.

Misconception

Input validation applies to values input by


the user. In this case, the requested input
is the sum of two numbers, each of which
are between 1 and 10. It is not necessary
to validate the random number generation
(as this has not been input) and it would be
inappropriate to limit user inputs to
between 1 and 10; the total could easily be
(for example) 8 + 6 = 14.

Where candidates suggested validating


inputs to allow between 1 and 10, not all
marks available were given due to this
misconception.

Total 14

© OCR 2024. You may photocopy this page. 256 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

63 1 mark per missing bit 4 Accept T / True


AO2 1b
A B Q (4) Examiner’s Comments
0 0 0
0 1 1 This question asked candidates to
1 0 1 complete a truth table for an OR logic gate,
1 1 1 with the correct answer being all 1s.

This relatively simple question firstly


assessed whether candidates understood
the use of truth tables in general, with half
the marks being given for the inputs,
regardless of the gate.

Secondly, this question assessed whether


candidates understood the outputs given
by an OR gate with these inputs.

As expected, the majority of candidates


were able to gain full marks for both of
these areas.

Total 4

64 OR gate with two inputs // AND gate 2


with two inputs
Diagram as shown in guidance with no
additional gates

Total 2

© OCR 2024. You may photocopy this page. 257 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

65 i 1 mark per bullet point 3 Shape must be accurate

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

ii 1 mark per bullet point 4 CAO

Correct completion of A and B inputs AO1


as 1 1 1b(1) A B P
0 output for 01 input
0 0 1
0 output for 10 input AO2
0 output for 11 input 1b(3) 0 1 0
1 0 0
1 1 0

Total 7

© OCR 2024. You may photocopy this page. 258 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

66 i A OR B 3 1 mark per gate. Correct symbols must be


NOT C (AO2 1b) used.
AND gate
NOT gate must have circle for inversion,
OR and AND must not have a circle

Mark the shape of each gate, not the name


written if given. Ignore any writing / notes.

Lines do not have to be drawn or joined up,


but if they are, gates must have the correct
number of inputs/outputs. Penalise once
then FT.

Examiner’s Comments

This question was answered extremely


well. Candidates were familiar with the
logic symbols required for each gate.

A few candidates missed the circle from


the NOT gate symbol (which turned this
into a buffer instead) or added a circle to
the AND and OR gates. This turned them
into NAND and NOR gates. These logic
gates are not on the GCSE specification,
but are covered at A Level. Teachers may
find it beneficial to briefly discuss these in
order to anticipate mistakes like these.

A small number of candidates drew


indistinct logic gate symbols and named
them instead, such as a rectangle with
AND written in; this was not credited with a
mark.

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.

“The output for each possible input” gains


both marks

© OCR 2024. You may photocopy this page. 259 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

Examiner’s Comments

It is clear that candidates have


experienced and used truth tables with
logic circuits. However, the majority were
not able to describe the truth table’s
purpose with precision.

A truth table defines the expected outputs


for a logic circuit depending on the inputs
given. Furthermore, the truth table covers
all possible permutations of inputs.

A logic circuit with three inputs (A,B and C)


will have 8 possible rows in a truth table to
cover the 8 possible ways that True and
False values for three inputs can be
arranged.

Misconception

The number of rows in a truth table


depends on the number of inputs. The
number of rows can be given by 2x, where
x is the number of inputs. Therefore, a truth
table with 3 inputs would have 23 rows, or
2 × 2 × 2 = 8 rows.

Exemplar 1

Here the candidate has achieved both


marks available; it is clear that every
variation of input is included in the truth
table and the output is very clearly linked to
these inputs.

iii 8 // eight 1 Accept other answers that equate to 8 (e.g.


(AO2 1a) 23)

Total 6

© OCR 2024. You may photocopy this page. 260 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

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.

If lines cross on diagram, give BOD.

If (A AND C) AND NOT B drawn, allow


NOT B as first input for BP3.

Examiner’s Comments

This logic question is based around a


typical outdoor light system. The majority
of candidates were able to show
understanding that both the switch (input
C) and the motion sensor (input A) need to
be triggered for the light (output Q) to be
on. However, some candidates missed the
description that this only occurs at
nighttime. Input B is the light sensor and so
a NOT gate is required on this input to fulfil
this requirement.

Given that AND gates generally have two


inputs and this system uses three inputs,
two AND gates were required. The mark
scheme credits any and all arrangements
of these to reach the correct output.

Examiners were also instructed to credit


use of a 3 input AND gate.

© OCR 2024. You may photocopy this page. 261 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

b 1 mark each 2 Allow A OR B // B OR A for logic gate 1


(AO2 1a) Allow A AND B // B AND A for logic gate 2
Logic gate 1: OR
Logic gate 2: AND If logic statement provided with multiple
gates (e.g. A OR B AND C) this is
incorrect.

Allow use of symbols (e.g. ∨, + for OR, ∧, .


for AND)

Allow correct drawing of logic gates.

Total 5

68 a To convert it to binary / machine code 1 Maximum 1 mark


The processor can only understand
machine code

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

69 Error diagnostics (any example) 2 1 mark per bullet to a maximum of 2


Run-time environment marks. Only 1 example per bullet, e.g. auto-
Editor (any feature such as auto- correct and auto-indent would only gain 1
correct, auto-indent) mark.
Translator
Version control
Break point
Stepping

Total 2

© OCR 2024. You may photocopy this page. 262 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

70 Error diagnostics (any example) 2 1 mark per bullet to a maximum of 2


Run-time environment (AO1 1a) marks.
Editor (any feature such as auto- Only 1 example per bullet, e.g. auto-correct
correct, auto-indent) and auto-indent would only gain 1 mark.
Translator
Version control
Break point
Stepping

Total 2

© OCR 2024. You may photocopy this page. 263 of 265 Created in ExamBuilder
Mark Scheme

Question Answer/Indicative content Marks Guidance

71 a One mark per row 4 Accept other markings that indicate a


choice has been made (e.g. a cross, etc)

Statement High-level Low-level


language language
Uses English- ✔
like keywords
such as print
and while
Must be ✔
translated
before the
processor can
execute code
Code written is ✔
portable
between
different
processors
Requires the ✔
programmer to
understand the
processor’s
registers and
structure

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

Question Answer/Indicative content Marks Guidance

72 1 mark per bullet to max 2 2 Accept “human language” as English for


BP4
Easier/quicker for humans to write AO1
Easier/quicker to read / understand / 1b(2) “Easier to use” is too vague.
remember
Easier/quicker to maintain / debug / Examiner’s Comments
spot errors Question (b) was answered extremely well.
…because code is closer to English / Many candidates were able to articulate
uses English words the advantages of high-level languages
Less code to write over assembly language. Even more
…because one HLL instruction pleasing were the many candidates able to
represents many assembly instructions discuss issues such as portability of code
Portable (between processors) // will and that a high-level instruction translates
work with different types of compute into many assembly instructions.

Total 2

© OCR 2024. You may photocopy this page. 265 of 265 Created in ExamBuilder

Powered by TCPDF (www.tcpdf.org)

You might also like