AQA GCSE Computer Science sample Paper 1, Question 18: the go-kart braking distance

AQA 8525 sample assessment material, Paper 1 Question 18: write a Python program that keeps asking for a speed until it is 10 to 50, divides it by 5 for the braking distance, multiplies by 1.5 if the ground is wet, and outputs it. A model answer, the eight marks, and the robot braking.

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

Question 18 is the last question of AQA's sample assessment material for GCSE Computer Science Paper 1 (8525/1B, the Python paper): 8 marks for a validation loop, a calculation, a yes-or-no question and an output.

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

  • Keep asking for the go-kart's speed until it is between 10 and 50 inclusive.
  • The braking distance in metres is the speed divided by 5.
  • Ask whether the ground is wet. The user enters yes if it is.
  • If wet, multiply the braking distance by 1.5.
  • Output the braking distance.

A model answer

speed = float(input("Speed in kph: "))
while speed < 10 or speed > 50:
    speed = float(input("Speed in kph: "))
brakingDistance = speed / 5
isWet = input("Is the ground wet? ")
if isWet == "yes":
    brakingDistance = brakingDistance * 1.5
print(brakingDistance)

Where the eight marks are

Two for design: a loop that validates the speed, and meaningful names with suitable data types (the braking distance must be real, the wet answer must be a string).

Six for a program that works: both inputs in sensible places; a while that asks again; a correct Boolean condition; the division by 5; selection that adjusts for wet ground; the output in the right place.

Any error caps you at 7. The mark scheme's 7 mark example has while speed <= 10 and speed > 50, which loses the condition mark and shows two slips at once.

Where the marks are lost

  • and in the loop. No speed is both under 10 and over 50. The loop must repeat while it is under 10 or over 50.
  • <= 10. 10 is allowed. Rejecting it is a boundary error.
  • The braking distance inside the loop. It is worked out once, after a valid speed is in.
  • if isWet == yes. Without quotation marks, yes is a variable that does not exist.
  • Halving by mistake. Wet ground makes the distance longer: times 1.5.

Run it

Enter a speed and whether it is wet. The robot then drives and brakes over the distance it worked out, with a metre scaled to a centimetre.

Try 60 (asked again), then 40: 8 metres, or 12 if you say yes to wet. The robot drives that far.
The program
from bugbot import *
connect()

speed = float(input("Speed in kph: "))
while speed < 10 or speed > 50:
    print("Speed must be from 10 to 50")
    speed = float(input("Speed in kph: "))
brakingDistance = speed / 5
isWet = input("Is the ground wet? ")
if isWet == "yes":
    brakingDistance = brakingDistance * 1.5
print(brakingDistance)
forward(100, distance=brakingDistance)
led("red")
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 18?

Input the speed and loop while it is less than 10 or more than 50, asking again. Divide by 5 for the braking distance. Input whether it is wet, and if the answer is yes multiply the distance by 1.5. Print the distance.

Why is it OR and not AND in a validation loop?

The loop must repeat when the value is invalid, and a value is invalid if it is too small or too big. It cannot be both, so AND would never be true and nothing would be checked.

Why should the braking distance be a real number?

Dividing a speed by 5 usually gives a fraction, and multiplying by 1.5 does too. Storing it as an integer would throw the fraction away.

More from this paper

Every AQA 8525 question we have worked

Learn it step by step

  1. F6.1 Defensive design and validation Robust programs
  2. F2.6 Condition-controlled loops: while Decisions and loops
  3. F13.4 Programming questions Exam preparation
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.