Tootips might not work so well on phones or tablets. Sorry.
AQA Computer Science GCSE
Programming Exam Question - Taxi firm
This is a seven mark paper 1 programming question. It was question 5 on the specimen 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 allows a taxi company to calculate how much a taxi fare should be.
The program should:
- allow the user to enter the journey distance in kilometres (no validation is required)
- allow the user to enter the number of passengers (no validation is required)
- calculate the taxi fare by
- charging £2 for every passenger regardless of the distance
- charging a further £1.50 for very kilometre regardless of how many passengers there are
- output the final fare
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.
[7 marks]
Hints
You can uncover a set of hints below.
- the first thing to do is to get the user to enter the two values needed - this is worth 2 marks by itself! 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 a mark (see the link above)
- there's a mark for using meaningful variable names even if you get the program very wrong indeed
- you don't need to add anything to the program: no need for a title, fancy outputs or anything like that. Just do the things the question wants
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 | Passengers: 3 Distance: 4 |
12 - this is expected data with a simple calculation. Both entries are integers; output is an integer |
Normal data | Passengers: 6 Distance: 3 |
16.50 - this is expected data with a simple calculation involving . Both entries are integers; output is a real number |
Boundary data | Passengers: 1 Distance: 1 |
3.50 - this is expected data but with the lowest values possible and a simple calculation. Both entries are integers |
To make your program more complicated, you could test entering real numbers for the distance. This is a more complete solution, but is not required by the markscheme - you can choose just to use integers.
Test type | Test data | Expected result |
Normal data | Passengers: 3 Distance: 3.14 |
10.71 - this is expected data with a calculation involving real numbers. One entry is a real number; the output is a real number |
Boundary data | Passengers: 1 Distance: 0.1 |
2.15 - this is expected data with the lowest values possible. One entry is a real number; the output is a real number |
I don't think there's any point testing invalid data in this case - entering 3.2 passengers or "fishy" for the distance is pointless as it should fail. If validation was required I'd be aiming to test these sorts of things for sure.
What is Validation?
You can find out more about validation and verification in the programming projects section of this site. Validation is something you need to know for Paper 1 exams - it's Unit 2, section 3.2.11
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 are a cohort 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 or 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.