Tootips might not work so well on phones or tablets. Sorry.
AQA Computer Science GCSE
Programming Exam Question – Go-kart braking distance
This is an eight mark paper 1 programming question. It was question 18 on the specimen exam paper – the last question on the exam paper.
I suggest trying to write an answer by hand first and then attempting to program your answer. Does it work? What did you get wrong?
The Question:
Write a Python program that calculates an estimate of the braking distance in metres for a new model of go-kart that is travelling between 10 and 50 kilometres per hour (kph).
The program should:
- keep asking the user to enter a speed for the go-kart until they enter a speed that is between 10 and 50 inclusive
- calculate the braking distance in metres by dividing the speed by 5
- ask the user if the ground is wet (expect the user to enter yes if it is
- if the ground is wet, multiply the braking distance by 1.5
- output the final calculated braking distance
You should use meaningful variable name(s), correct syntax and indentation in your answer.
The answer grid contains vertical lines to help you indent your code accurately.
[8 marks]
Hints
You can uncover a set of hints below.
- follow the list of things the program should do through in order. If you don't know how to do part of it, leave a big gap and come back to it. If you really can't figure out how to do it, just write something like "code to calculate the distance goes here" so that the examiner can see the flow of your program
- there are marks for getting data input, using variables and converting inputs to the right data type. I have a page about how to input (and output) values if you need it
- data entered in Python always comes in as a string. You need to convert it – this is worth marks (see the link above)
- there are marks for the calculation – so a mark for dividing something by five in the right sort of place
- there is a mark for outputting the final value, so long as you do it in "a logically correct place" (that means "at the end" – see my point about leaving a big gap and writing what would happen in that section if necessary
Note that question 16 on the exam paper pretty much gives the answer away for how to do this part. It would be worth looking at it...
Suggested Test Data:
Because no validation is required, you could enter any values. I don't think you need to make this too complicated, so start with just integers as the data entry values. I'd suggest the following as simple tests:
Test type | Test data | Expected result |
Normal data | Speed: 30 Wet: no |
6 – tests a standard value with not wet ground – anything other than yes could be entered here |
Normal data | Speed: 30 Wet: yes |
9 – tests a standard value with wet ground |
Normal data | Speed: 15 Wet: yes |
11.25 – tests a standard value which creates a real number output |
Boundary data | Speed: 10 Wet: yes |
3 – this is expected data but with the lowest value possible for speed |
Boundary data | Speed: 50 Wet: Yes |
25 – this is expected data but with the highest value possible for speed. It also tests whether Yes is handled properly – the question specifically references to expect an input of yes for wet ground |
Boundary data | Speed: 9 | Ask for input again – this is a value immediately outside the accepted range and should be rejected |
Boundary data | Speed: 51 | Ask for input again – this is a value immediately outside the accepted range and should be rejected |
You could also test other values for speed that are far outside the expected range (0, -25, 78 etc...) and also real numbers – there's no need to deal with these, but you could do if you chose to.
A note about copyright
The question text has been published openly on the web by AQA. That is copyrighted to them. The other words on this page are mine.
I'm using this here because the children I teach need to work on how they write exam answers – and the groups I published them for originally were cohorts massively impacted by COVID. I think, given that the questions have been published openly, that there is a fair-use educational rationale for putting them up here.
Note that I'm not putting them in a book, selling them on the TES, gaining any advertising revenue, or being paid in any other way for running this website. But I am aware that I'm in a copyright grey area. If that's a problem, contact me.