BREAKING
Student's code works, nobody knows why, including student★Local teen writes pseudocode, accidentally invents a language★Binary joke told in class, exactly 10 students laugh★
  1. Home
  2. GCSE
  3. Computer Science
  4. OCR
  5. Data types

OCR GCSE Computer Science

Topic questions Programming fundamentals Data types

Data types

7 questions · 151 marks · about 3 hours

Data types questions

OCR J277 Data types 7 questions

Computational thinking, algorithms and programming June 2025, Question 4 6 marks

An algorithm is written to read numbers from the external text file data.txt

Each number is checked when it is read from the external text file. The number is output to the user if it is not 0.

(a)

Complete the algorithm using the OCR Exam Reference Language statements in the box.

Not all statements are used.

data for if

myFile.close() myFile.readLine() input()

myFile.writeLine() open print

temp txt x

myFile =........ ("data.txt")

while NOT myFile.endOfFile()

if int (........) != 0

endif

endwhile

[5]
Reveal mark scheme Mark scheme for question 4(a)
(b)

Identify how casting is used in this algorithm.

[1]
Reveal mark scheme Mark scheme for question 4(b)

Computational thinking, algorithms and programming June 2025, Question 6 30 marks

OCR Rockfest is a yearly music festival. Visitors buy tickets to attend and watch the music acts.

A computer system is created to sell tickets and store information about visitors and the music acts.

(a)

Visitors are asked to choose a password. The password is entered twice and stored in the variables passA and passB

(a)(i)

Tick (✓) one box to identify the correct OCR Exam Reference Language statements for the design of this task.

Figure for question 6
[1]
Reveal mark scheme Mark scheme for question 6(a)(i)
(a)(ii)

Design an algorithm that:

• checks if the passwords stored in passA and passB are the same

• outputs "passwords match" if they are the same

• outputs "passwords do not match" if they are not the same.

[3]
Reveal mark scheme Mark scheme for question 6(a)(ii)
(b)

The database table TblMusic stores data about the music acts.

Some of the data in TblMusic is shown:

ActIDStageDaySetLength
1PlatinumSaturday0.5
2HillsSaturday1.5
3TriangleSunday1.0
4PlatinumSunday0.5

An SQL statement has been written to show ActID and Stage for all acts playing on Saturday. The SQL statement is incorrect.

SELECT ActID AND Stage FROM TblActs IF Day = Saturday

(b)(i)

Refine the SQL statement to correct the errors.

[4]
Reveal mark scheme Mark scheme for question 6(b)(i)
(b)(ii)

Identify one example of a record from TblMusic

[1]
Reveal mark scheme Mark scheme for question 6(b)(ii)
(b)(iii)

Give the most appropriate data type for each field shown.

Figure for question 6
[2]
Reveal mark scheme Mark scheme for question 6(b)(iii)
(c)

Tickets to the festival are £60 each. Visitors can buy multiple tickets. For example, a visitor buying 4 tickets would pay £240.

(c)(i)

Write a function, calculatePrice() that:

• takes the number of tickets to be purchased as a parameter

• calculates and returns the total price to pay.

You must use either:

• OCR Exam Reference Language, or

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

[4]
Reveal mark scheme Mark scheme for question 6(c)(i)
(c)(ii)

Write an algorithm that:

• uses the function calculatePrice() to find the price for a visitor buying 3 tickets

• stores the result in the variable totalPrice

You must use either:

• OCR Exam Reference Language, or

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

[2]
Reveal mark scheme Mark scheme for question 6(c)(ii)
(d)

The number of different music acts on each of the three stages is stored in the array actNumbers.

Each index of the array represents one stage.

Question 6, shown as an image
Figure for question 6
Question 6, shown as an image

This algorithm adds up the total number of acts on all three stages.

01 count = 0

02 for x = 0 to 2

03 count = count + actNumbers[x]

04 next x

05 print(count)

(d)(i)

Complete the trace table for the algorithm. You may not need to use all rows in the table.

Figure for question 6
[4]
Reveal mark scheme Mark scheme for question 6(d)(i)
(d)(ii)

The array actNumbers is changed to include data for two more stages. The new array is shown:

Index 0 1 2 3 4

Figure for question 6

The algorithm from part (i) needs refining to work for the new array. The algorithm is repeated here:

01 count = 0

02 for x = 0 to 2

03 count = count + actNumbers[x]

04 next x

05 print(count)

Identify the line number that will need to be changed for the new array and write the updated line of code.

[2]
Reveal mark scheme Mark scheme for question 6(d)(ii)
(d)(iii)

Refine line 05 in the algorithm to output "The total act count is " and then the content of the variable count

For example:

The total act count is 50

[1]
Reveal mark scheme Mark scheme for question 6(d)(iii)
(e)

There are 500 tickets available for the music festival. The number of tickets currently available is stored in the variable tickets

Complete the algorithm to:

• prompt the user to enter how many tickets they would like and take this value as input

• output "Tickets booked" and reduce the value stored in tickets if there are enough tickets available

• output "Not enough tickets" if there are not enough tickets available

• repeat the steps until there are no tickets left.

You must use either:

• OCR Exam Reference Language, or

• a high-level programming language that you have studied

tickets = 500

[6]
Reveal mark scheme Mark scheme for question 6(e)

Computational thinking, algorithms and programming June 2024, Question 6 6 marks

The variable message is assigned a value.

message = "abcd1234"

(a)

Complete the table to show the output when each statement executes.

The first output has been completed for you.

StatementOutput
print(message.length)8
print(message.upper)
print(message.left(4))
print(int(message.right(4))*2)
[3]
Reveal mark scheme Mark scheme for question 6(a)
(b)

Write an algorithm in pseudocode to:

• store "Hello" in the variable word1

• store "Everyone" in the variable word2

• concatenate word1 and word2 to store "HelloEveryone" in the variable message

[3]
Reveal mark scheme Mark scheme for question 6(b)

Computational thinking, algorithms and programming June 2024, Question 9 30 marks

Students take part in a sports day. The students are put into teams.

Students gain points depending on their result and the year group they are in. The points are added to the team score.

The team with the most points at the end of the sports day wins.

(a)

Data about the teams and students is stored in a sports day program.

(a)(i)

Identify the most appropriate data type for each variable used by the program.

Each data type must be different.

VariableExampleData type
teamName"Super-Team"
studentYearGroup11
javelinThrow18.2
[3]
Reveal mark scheme Mark scheme for question 9(a)(i)
(a)(ii)

The student names for a team are stored in an array with the identifier theTeam

An example of the data in this array is shown:

Index 0 1 2 3 4 5

Figure for question 9

A linear search function is used to find whether a student is in the team. The function:

• takes a student name as a parameter

• returns True if the student name is in the array

• returns False if the student name is not in the array.

Complete the design of an algorithm for the linear search function.

function linearSearch(studentName)

for count = 0 to …………….….....……………

[4]
Reveal mark scheme Mark scheme for question 9(a)(ii)
(b)

endif

next count

return False

endfunction

Figure for question 9
[4]
Reveal mark scheme Mark scheme for question 9(b)
(c)

The height a student jumps in the high jump needs to be input and validated. The height is entered in centimetres (cm) and must be between 40.0 and 180.0 inclusive.

(c)(i)

Write an algorithm to:

• take the height jumped as input

• output "VALID" or "NOT VALID" depending on the height input.

You must use either:

• OCR Exam Reference Language, or

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

[4]
Reveal mark scheme Mark scheme for question 9(c)(i)
(c)(ii)

The algorithm is tested using a range of tests.

Complete the table to identify an example of test data for each type of test.

Test data (height jumped in cm)Type of testExpected output
Normal"VALID"
Boundary"VALID"
Erroneous"NOT VALID"
[3]
Reveal mark scheme Mark scheme for question 9(c)(ii)
(d)

The individual results for each student in each event are stored in a database.

The database table TblResult stores the times of students in the 100 m race. Some of the data is shown:

StudentIDYearGroupTeamNameTime
11GC111Valiants20.3
10VE110Super-Team19.7
10SM110Super-Team19.2
11JP211Champions19.65

Complete the SQL statement to show the Student ID and team name of all students who are in year group 11

SELECT StudentID,........

[4]
Reveal mark scheme Mark scheme for question 9(d)
(e)

Abstraction and decomposition have been used in the design of the sports day program.

(e)(i)

Identify one way that abstraction has been used in the design of this program.

[1]
Reveal mark scheme Mark scheme for question 9(e)(i)
(e)(ii)

Identify one way that decomposition has been used in the design of this program.

[1]
Reveal mark scheme Mark scheme for question 9(e)(ii)
(f)

An algorithm works out which team has won (has the highest score).

Write an algorithm to:

• prompt the user to enter a team name and score, or to enter "stop" to stop entering new teams

• repeatedly take team names and scores as input until the user enters "stop"

• calculate which team has the highest score

• output the team name and score of the winning team in an appropriate message.

You must use either:

• OCR Exam Reference Language, or

• A high-level programming language that you have studied

[6]
Reveal mark scheme Mark scheme for question 9(f)

Computational thinking, algorithms and programming June 2023, Question 6 30 marks

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 storedVariable identifierExample data
The user’s nameUserNameAdmin123
A telephone number to call when the alarm is activatedEmergencyPhoneNumber+449999999999
Whether a door sensor is activatedDoorSensorActiveTrue
Whether a window sensor is activatedWindowSensorActiveTrue
A timer that counts, to the nearest second, how long a door sensor has been activatedDoorActiveTime100
A timer that counts, to the nearest second, how long a window sensor has been activatedWindowActiveTime100
Whether the system is armedSystemArmedTrue
Whether the system is in test modeTestModeActiveTrue
(a)

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.

Figure for question 6
[4]
Reveal mark scheme Mark scheme for question 6(a)
(b)

The 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]
Reveal mark scheme Mark scheme for question 6(b)
(c)
Figure for question 6
(c)(i)

Give the line number where there is concatenation.

[1]
Reveal mark scheme Mark scheme for question 6(c)(i)
(c)(ii)

Give the identifier of a variable used in the program.

[1]
Reveal mark scheme Mark scheme for question 6(c)(ii)
(c)(iii)

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

[1]
Reveal mark scheme Mark scheme for question 6(c)(iii)
(c)(iv)

Give the line number that contains a function call.

[1]
Reveal mark scheme Mark scheme for question 6(c)(iv)
(c)(v)

Identify two programming constructs that have been used in the program.

[2]
Reveal mark scheme Mark scheme for question 6(c)(v)
(d)

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

FieldnameDescription
DateThe date the event happened
SensorIDThe sensor that was activated
SensorTypeThe type of sensor that was activated – Door, Motion or Window
LengthThe 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:

DateSensorIDSensorTypeLength
05/02/2023WS2Window38
05/02/2023MS1Motion2
06/02/2023DS3Door1
06/02/2023MS2Motion3
06/02/2023MS1Motion2
07/02/2023WS1Window24
07/02/2023DS1Door1

Write an SQL statement to display the sensor IDs of the door sensors that have been triggered for more than 20 seconds.

[3]
Reveal mark scheme Mark scheme for question 6(d)
(e)

A program written in a high-level language is used to access the data from the database. This program has a procedure, SaveLogs(), that stores the data to an external text file.

The procedure SaveLogs():

• 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]
Reveal mark scheme Mark scheme for question 6(e)
(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 high-level 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.

DateSensorIDSensorTypeLength
05/02/2023WS2Window38
05/02/2023MS1Motion2
06/02/2023DS3Door1
06/02/2023MS2Motion3
06/02/2023MS1Motion2
07/02/2023WS1Window24
07/02/2023DS1Door1

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

(f)(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]
Reveal mark scheme Mark scheme for question 6(f)(i)
(f)(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.

[6]
Reveal mark scheme Mark scheme for question 6(f)(ii)

Computational thinking, algorithms and programming June 2022, Question 2 19 marks

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:

InputValue
AIs a student
BHas a discount card
CThe current day is Saturday
(a)

The logic system P = (A OR B) AND NOT C is used.

(a)(i)

Complete the following logic diagram for P = (A OR B) AND NOT C by drawing one logic gate in each box.

Figure for question 2
[3]
Reveal mark scheme Mark scheme for question 2(a)(i)
(a)(ii)

A truth table can be produced for this logic circuit.

Describe the purpose of a truth table.

[2]
Reveal mark scheme Mark scheme for question 2(a)(ii)
(a)(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]
Reveal mark scheme Mark scheme for question 2(a)(iii)
(b)

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.

[5]
Reveal mark scheme Mark scheme for question 2(b)
(c)

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]
Reveal mark scheme Mark scheme for question 2(c)
(d)
Figure for question 2
(d)(i)

Define the term casting and give the line number where casting has been used in the algorithm.

[2]
Reveal mark scheme Mark scheme for question 2(d)(i)
(d)(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.

Figure for question 2
[4]
Reveal mark scheme Mark scheme for question 2(d)(ii)

Computational thinking, algorithms and programming June 2022, Question 5 30 marks

Customers at a hotel can stay between 1 and 5 (inclusive) nights and can choose between a basic room or a premium room.

(a)

A typical booking record is shown in the table:

firstNameAmaya
surnameTaylor-Ling
nights3
roomPremium
stayCompleteFalse
(a)(i)

State the most appropriate data type for the following fields:

[2]
Reveal mark scheme Mark scheme for question 5(a)(i)
(a)(ii)

Give the name of one field that could be stored as a Boolean data type.

[1]
Reveal mark scheme Mark scheme for question 5(a)(ii)
(a)(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]
Reveal mark scheme Mark scheme for question 5(a)(iii)
(b)

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.

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

[5]
Reveal mark scheme Mark scheme for question 5(b)(i)
(b)(ii)

Complete the following test plan to check whether the number of nights is validated correctly.

Test data (number of nights)Type of testExpected output
2ALLOWED
BoundaryALLOWED
Erroneous / InvalidNOT ALLOWED
[3]
Reveal mark scheme Mark scheme for question 5(b)(ii)
(c)

A Basic room costs £60 each night. A Premium room costs £80 each night.

(c)(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]
Reveal mark scheme Mark scheme for question 5(c)(i)
(c)(ii)

Write program code, that uses newPrice(), to output the price of staying in a Premium room for 5 nights.

You must use either:

• OCR Exam Reference Language, or

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

[3]
Reveal mark scheme Mark scheme for question 5(c)(ii)
(d)

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

Question 5, shown as an image
Index012345678
Data213210041

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]
Reveal mark scheme Mark scheme for question 5(d)
(e)

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

[6]
Reveal mark scheme Mark scheme for question 5(e)

Report a problem with a question on this page
What is wrong?

Goes to whoever maintains the question split. No account needed and nothing is published on this page.

Memes

Certified Computer Science memes. Peer-reviewed by nobody.

Laugh now. Cry in the exam hall later. Then come back and do a past paper.

Write a proper algorithm
Write ‘sort it’ and leave
Me on the 6-mark pseudocode question
Debugging with print statements
Using a trace table
Knowing the difference between = and ==
Explaining recursion by explaining recursion
Code enlightenment, ranked

Mum 💖

can you fix the wifi since you do computers 🥰

that's not what computer science is

so that's a no then

📱 Screen time this week · Discord8h 2m

Turned it off and on again

Computer Science starter pack

Laptop with 47 tabs openPython error on line 1Counting binary on fingersThis website
Compiled with zero errors