AQA GCSE Computer Science June 2024 Paper 1, Question 2: NOT, OR and ELSEIF

AQA 8525 June 2024 Paper 1, Question 2: follow an IF, ELSEIF, ELSE algorithm that uses NOT, OR, AND and MOD. Which input gives True, which give Unknown, and how to rewrite NOT(num > 1). Worked through, with the algorithm to run on every number.

Past paper questionAQA 8525/1BJune 2024 Paper 15 marksRead the code

Question 2 of the AQA GCSE Computer Science Paper 1 sat on 15 May 2024 (8525/1B, the Python paper) is five one mark parts about a ten line algorithm with four branches. The way through it is to turn the conditions into ranges of numbers first.

We do not copy the exam paper here. Open it beside this page: AQA June 2024 Paper 1B question paper (PDF). When you have finished, check the mark scheme too.

The question in short

The algorithm reads num. Then:

  • if NOT(num > 1) OR num > 20, it outputs False;
  • else if num > 1 AND num < 15, it outputs Almost;
  • else if num MOD 5 = 0, it outputs True;
  • else it outputs Unknown.

Turn it into ranges

NOT(num > 1) means num is 1 or less. So the first branch catches 1 or less, and 21 or more.

The second branch catches 2 to 14.

Only 15 to 20 can reach the last two branches. Of those, the multiples of 5 (15 and 20) give True. The rest (16, 17, 18, 19) give Unknown.

num Output
1 or less False
2 to 14 Almost
15, 20 True
16, 17, 18, 19 Unknown
21 or more False

The five parts

2.1 Where is a relational operator first used? Line 2, in num > 1. Line 1 only assigns.

2.2 The output for 5. 5 is in 2 to 14: Almost. Yes, 5 is a multiple of 5, but an ELSEIF is only reached when every branch above it has failed.

2.3 Which input gives True? Of -1, 10, 20 and 21, only 20 lands in the 15 to 20 range. 10 is a multiple of 5, but it is caught by Almost first.

2.4 Rewrite line 2 without NOT. IF num ≤ 1 OR num > 20 THEN. The opposite of "greater than 1" is "less than or equal to 1". num < 2 is accepted too.

2.5 An input that gives Unknown. 16, 17, 18 or 19. Any one.

Where the marks are lost

  • True for an input of 5 or 10. Order matters in an ELSEIF chain. The first true branch wins.
  • num < 1 for 2.4. The opposite of > is , not <. With < 1, an input of exactly 1 would change branch.
  • 15 for 2.5. 15 MOD 5 is 0, so it gives True.
  • Several answers for 2.5, one of them wrong. The mark scheme rejects the lot. Give one.

Run it

The algorithm as a function, run on every number from -1 to 22, so that you can see the ranges. WITHOUT_NOT switches to your rewritten line 2. The outputs should not change.

It prints False, Almost, True and Unknown for each number. Set WITHOUT_NOT to True: every line should stay the same.
The program
from bugbot import *
connect()

# True uses the rewritten line 2 from part 2.4
WITHOUT_NOT = False

def answer(num):
    if WITHOUT_NOT:
        first = num <= 1 or num > 20
    else:
        first = not (num > 1) or num > 20
    if first:
        return "False"
    elif num > 1 and num < 15:
        return "Almost"
    elif num % 5 == 0:
        return "True"
    else:
        return "Unknown"

for num in range(-1, 23):
    print(num, answer(num))
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 are the answers to AQA GCSE Computer Science 2024 Paper 1 Question 2?

2.1 is B, line 2. 2.2 is A, Almost. 2.3 is C, 20. 2.4 is IF num ≤ 1 OR num > 20 THEN. 2.5 is any of 16, 17, 18 or 19.

How do I remove NOT from a condition?

Replace the comparison with its opposite. NOT(x > 1) becomes x ≤ 1. NOT(x = 1) becomes x ≠ 1. NOT(x ≤ 1) becomes x > 1.

In an IF ELSEIF chain, can two branches run?

No. The conditions are tested from the top, the first one that is true runs, and the rest are skipped, even if they would also have been 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. F1.9 Arithmetic operators Programming basics
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.