OCR GCSE Computer Science June 2025 Paper 2, Question 6(c): the calculatePrice function

OCR J277/02 June 2025, Question 6(c): write a function calculatePrice that takes a number of tickets and returns the price at 60 pounds each, then call it for 3 tickets and store the result in totalPrice. The marks explained, with the function to run.

Past paper questionOCR J277/02June 2025 Paper 26 marksWrite a program

Question 6(c) of the OCR GCSE Computer Science Paper 2 sat on 20 May 2025 (J277/02) is two short pieces of code: define a function (4 marks), then call it and store what comes back (2 marks). Six marks for four lines, if you keep the two jobs apart.

We do not copy the exam paper here. Open it beside this page: OCR June 2025 J277/02 question paper (PDF). When you have finished, check the mark scheme too.

The question in short

Festival tickets are £60 each. Write a function, calculatePrice(), that takes the number of tickets as a parameter, and calculates and returns the total price.

Then write an algorithm that uses calculatePrice() to find the price of 3 tickets, and stores the result in the variable totalPrice.

Part (i): define it

In OCR Exam Reference Language:

function calculatePrice(tickets)
    price = tickets * 60
    return price
endfunction

In Python:

def calculatePrice(tickets):
    price = tickets * 60
    return price

The four marks: a function definition called calculatePrice; a parameter that is not overwritten; multiplying the parameter by 60; returning the price.

Part (ii): call it

totalPrice = calculatePrice(3)

One mark for calling the function with 3. One for storing the result in totalPrice.

Where the marks are lost

  • print(price) in the function. The mark scheme says it must be return, and does not credit output.
  • tickets = input() in the function. That overwrites the parameter.
  • x for multiply. This is Section B: it has to be real code, and the operator is *.
  • == in part (ii). totalPrice == calculatePrice(3) compares. One equals sign stores.
  • Defining the function again in part (ii). It asks you to use it.
  • print(calculatePrice(3)) for part (ii). The question says to store the result in totalPrice. Read what is asked.

Run it

The function and the call, then a price for any number of tickets you type. The robot drives 1 cm for every £10.

totalPrice is 180 for 3 tickets. Then try 4 tickets for 240, the example in the question.
The program
from bugbot import *
connect()

def calculatePrice(tickets):
    price = tickets * 60
    return price

totalPrice = calculatePrice(3)
print("totalPrice is", totalPrice)

wanted = int(input("How many tickets? "))
cost = calculatePrice(wanted)
print(wanted, "tickets cost", cost, "pounds")
forward(60, distance=min(cost / 10, 60))
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

Questions

What is the answer to OCR J277 June 2025 Paper 2 Question 6(c)?

Part (i): function calculatePrice(tickets), price = tickets * 60, return price, endfunction. Part (ii): totalPrice = calculatePrice(3).

What is a parameter?

A variable named in a function's header that receives a value when the function is called. In calculatePrice(tickets), tickets is the parameter, and in calculatePrice(3) the value 3 is passed to it.

What is the difference between a function and a procedure?

A function returns a value to the code that called it. A procedure carries out a task without returning a value.

More from this paper

Every OCR J277 question we have worked

Learn it step by step

  1. F4.1 Writing functions Functions and structured code
  2. F4.2 Parameters and return values Functions and structured code
Open the lessons

This is our own explanation of a published exam question. It is not written or endorsed by OCR, and the question paper and mark scheme remain OCR's copyright. Read them on OCR's site with the links on this page.