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. Variables, constants, inputs, outputs and assignment

OCR GCSE Computer Science

Topic questions Programming fundamentals Variables, constants, inputs, outputs and assignment

Variables, constants, inputs, outputs and assignment

7 questions · 101 marks · about 2 hours

Variables, constants, inputs, outputs and assignment questions

TopicVariables, constants, inputs, outputs and assignment

OCR J277 Variables, constants, inputs, outputs and assignment 7 questions

Computational thinking, algorithms and programming June 2025, Question 1 9 marks

A program asks a user to enter a number. Only integer values between 1 and 100 (inclusive) are accepted. The program is tested.

(a)

Tick (βœ“) one or more boxes in each row to identify the type or types of test for each example of test data.

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

An algorithm is written for the program.

(b)(i)

Complete the algorithm for the program.

num = input("Enter a number between 1 and 100")

if num........ AND........ then

print("accepted")

print("not accepted")

endif

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

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

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

Give one Boolean operator used in the algorithm in part (b)(i).

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

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 2023, Question 1 11 marks

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

Figure for question 1
[4]
Reveal mark scheme Mark scheme for question 1(a)
(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]
Reveal mark scheme Mark scheme for question 1(b)
(c)

Three incomplete pseudocode algorithms are given with a description of the purpose of each algorithm.

Write the missing arithmetic operator for each algorithm.

(c)(i)

Outputting 12 to the power of 2.

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

Finding the difference between two measurements.

measurement1 = 300 measurement2 = 100

difference = measurement1 ……………… measurement2

[1]
Reveal mark scheme Mark scheme for question 1(c)(iii)
(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.

Figure for question 1
[3]
Reveal mark scheme Mark scheme for question 1(d)

Computational thinking, algorithms and programming June 2023, Question 3 8 marks

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

(a)

Describe the purpose of the variable temp in the insertion sort pseudocode algorithm.

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

A bubble sort is another type of sorting algorithm.

(c)(i)

Describe one difference between an insertion sort and a bubble sort.

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

Describe two similarities between an insertion sort and a bubble sort.

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

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 1 7 marks

(a)

Tick (βœ“) one box in each row to identify whether the OCR Reference Language code given is an example of selection or iteration.

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

Write pseudocode to increment the value held in the variable score by one.

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

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

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