AQA GCSE Computer Science June 2022 Paper 1, Question 8: the bonus payment program
AQA 8525 June 2022 Paper 1, Question 8: write a Python program that works out a bonus from items sold and years employed, using AND and ELIF. A model answer, a test table, the seven marks explained, and the program to run.
Question 8 of the AQA GCSE Computer Science June 2022 Paper 1 (8525/1B, the Python paper) is a 7 mark "write a program" question about selection with more than one condition. The rules are given in words, and the marks are for turning the words into correct Boolean expressions.
We do not copy the exam paper here. Open it beside this page: AQA June 2022 Paper 1B question paper (PDF). When you have finished, check the mark scheme too.
The question in short
The program gets the number of items an employee has sold and the number of years they have been employed. It outputs their bonus:
- 2 years or less and more than 100 items sold: the bonus is the items sold times 2;
- more than 2 years: the bonus is the items sold times 10;
- otherwise, the bonus is 0.
Plan before you write
Three rules, three branches: if, elif, else. Underline the comparison words in the question and turn each into an operator.
| Words | Python |
|---|---|
| less than or equal to 2 | years <= 2 |
| greater than 100 | items > 100 |
| greater than 2 | years > 2 |
A model answer
items = int(input("Items sold: "))
years = int(input("Years employed: "))
if years <= 2 and items > 100:
bonus = items * 2
elif years > 2:
bonus = items * 10
else:
bonus = 0
print(bonus)
You can nest the tests instead: an outer if years <= 2 with an inner if items > 100. Both get full marks.
Test it
Pick values on each side of each boundary.
| Items | Years | Which rule | Bonus |
|---|---|---|---|
| 150 | 1 | first | 300 |
| 150 | 2 | first (2 is "less than or equal to 2") | 300 |
| 100 | 2 | otherwise (100 is not "greater than 100") | 0 |
| 50 | 3 | second | 500 |
| 0 | 5 | second | 0 |
Where the seven marks are
Three marks are for design: meaningful variable names, using selection, and using nested selection or more than one condition.
Four marks are for a program that works:
- both inputs stored correctly;
- a correct test of the years;
- correct Boolean expressions throughout;
- the right bonus output in each separate branch.
Any error in the code caps you at 6.
Where the marks are lost
years < 2. "Less than or equal to" needs<=. Someone in their second year would get the wrong bonus.items >= 100. "Greater than 100" does not include 100.orfor "and". Withor, a new employee who sold 5 items would match the first rule.- No
else. Thenbonushas no value for a new employee with low sales, andprint(bonus)crashes. The "otherwise" rule is a mark. - No
int."150" * 2is150150, and"1" <= 2is an error.
Run it
The robot celebrates in proportion: it drives 1 cm for every 10 pounds of bonus, up to 60 cm.
The program
from bugbot import *
connect()
items = int(input("Items sold: "))
years = int(input("Years employed: "))
if years <= 2 and items > 100:
bonus = items * 2
elif years > 2:
bonus = items * 10
else:
bonus = 0
print(bonus)
if bonus > 0:
led("green")
forward(60, distance=min(bonus // 10, 60))
else:
led("red")
Questions
What is the answer to AQA GCSE Computer Science 2022 Paper 1 Question 8?
Read items and years as integers. If years is 2 or less and items is more than 100, the bonus is items times 2. Else if years is more than 2, the bonus is items times 10. Otherwise it is 0. Print the bonus.
When should I use elif and not a second if?
Use elif when only one of the branches should run. With two separate ifs, both conditions are tested and both blocks can run. With if and elif, the second is only tested when the first was False.
What is the difference between AND and OR?
A condition joined with AND is True only when both parts are True. A condition joined with OR is True when either part is True.
More from this paper
- Question 7: Ask for an email address twice and check that they match 5 marks
- Question 13.1: Keep asking until a number is between 1 and 100 4 marks
- Question 13.2: Find a run of five in a sorted array of 100 cards 6 marks
- Question 14.2: Write a subroutine that counts the asterisks on a bingo ticket 8 marks
Every AQA 8525 question we have worked · Guide: Logic gates and truth tables explained
Learn it step by step
- F2.3 else, elif and Boolean operators Decisions and loops
- F2.4 Nested selection and match Decisions and loops
- F13.4 Programming questions Exam preparation
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.