AQA GCSE Computer Science sample Paper 1, Question 5: the taxi fare

AQA 8525 sample assessment material, Paper 1 Question 5: write a Python program that charges 2 pounds a passenger plus 1.50 a kilometre and outputs the fare. A model answer, the seven marks including data types, and the program to run.

Past paper questionAQA 8525/1BSample Paper 17 marksWrite a program

Question 5 of AQA's sample assessment material for GCSE Computer Science Paper 1 (8525/1B, the Python paper) is a 7 mark "write a program" question with no selection and no loop: two inputs, one sum, one output. The marks are in getting the data types right.

We do not copy the paper here. Open it beside this page: AQA 8525 Paper 1B sample question paper (PDF). When you have finished, check the sample mark scheme too.

The question in short

A taxi company charges £2 for every passenger, whatever the distance, plus £1.50 for every kilometre, whatever the number of passengers. The program inputs the distance in kilometres and the number of passengers (no validation needed), and outputs the fare.

A model answer

distance = float(input("Distance in km: "))
passengers = int(input("Number of passengers: "))
fare = 2 * passengers + 1.5 * distance
print(fare)

Where the seven marks are

Two are for design: meaningful variable names, and suitable data types. The distance can be real or integer, but the number of passengers must be an integer.

Five are for a program that works: the distance input; the passengers input; £2 a passenger; £1.50 a kilometre; the fare output.

Any error caps you at 6. The mark scheme's own 6 mark example leaves the float off the distance and loses the data type mark.

Where the marks are lost

  • No conversion at all. input() gives strings, and 2 * "3" is "33". Both inputs need int() or float().
  • float for passengers. People come in whole numbers. The mark scheme says integer.
  • £1.50 in the code. Write 1.5.
  • Working out the fare in two lines and printing the first. fare = 2 * passengers then fare = 1.5 * distance throws the first part away.

Run it

Type a distance and a number of passengers. The robot drives 1 cm for every pound.

10 km with 3 passengers is 6 + 15 = 21. Try 2.5 km with 1 passenger for 5.75.
The program
from bugbot import *
connect()

distance = float(input("Distance in km: "))
passengers = int(input("Number of passengers: "))
fare = 2 * passengers + 1.5 * distance
print(fare)
forward(60, distance=min(fare, 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 AQA sample Paper 1 Question 5?

Input the distance as a float and the passengers as an integer, set fare to 2 * passengers + 1.5 * distance, and print the fare.

Which data type should a number of people be?

Integer. A count of people is always a whole number, and AQA gives a design mark for choosing the right data types.

Why does input need int or float in Python?

input() always returns a string. Arithmetic on a string either fails or does something else, such as repeating it, so the string is converted first.

More from this paper

Every AQA 8525 question we have worked

Learn it step by step

  1. F1.9 Arithmetic operators Programming basics
  2. F1.8 Data types and casting Programming basics
  3. F1.7 Input from the user Programming basics
Open the lessons

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