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.

Past paper questionAQA 8525/1BJune 2022 Paper 17 marksWrite a program

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.
  • or for "and". With or, a new employee who sold 5 items would match the first rule.
  • No else. Then bonus has no value for a new employee with low sales, and print(bonus) crashes. The "otherwise" rule is a mark.
  • No int. "150" * 2 is 150150, and "1" <= 2 is an error.

Run it

The robot celebrates in proportion: it drives 1 cm for every 10 pounds of bonus, up to 60 cm.

Try the rows of the test table: 150 and 1 gives 300, 100 and 2 gives 0, 50 and 3 gives 500.
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")
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 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

Every AQA 8525 question we have worked · Guide: Logic gates and truth tables explained

Learn it step by step

  1. F2.3 else, elif and Boolean operators Decisions and loops
  2. F2.4 Nested selection and match 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.