Core Concepts

The building blocks of all logic. Every software application relies on Sequence, Selection, Iteration, and mathematical Operators.

The Three Constructs

Sequence

Instructions executed one after another in order. If line 1 depends on line 3, your programme will crash.

Selection

Making decisions. Checking if a condition is True or False, and branching logic accordingly.

if score > 50:
  print("Pass")

Iteration

Looping blocks of code.

  • Count-controlled: Loops a set number of times (FOR loop).
  • Condition-controlled: Loops until a boolean state changes (WHILE loop).

Examiner's Eye - The Inequality Trap!

A massive point of failure for students is confusing the < (less than) and > (greater than) symbols in Selection and Iteration loops. To avoid losing marks, always mentally read the symbol aloud as part of a sentence: if age < 18 reads as "If age is LESS THAN 18".

Boolean Logic Operators

Conditions are often combined. You must know what these three logic operators do:

AND

True ONLY if both conditions evaluate to True.

(5 > 3) AND (10 == 10) -> True

OR

True if at least one condition evaluates to True.

(5 < 1) OR (10 == 10) -> True

NOT

Inverts the result (True becomes False, False becomes True).

NOT (5 == 5) -> False

The Operator Sandbox

J277 requires you to know exactly how Arithmetic operators behave. Test the tricky ones like DIV and MOD below.

=
3

DIV (Integer Division): Returns how many times 3 fits whole into 10, throwing away the remainder.

Examiner's Eye - The DIV Trap!

In programming scenarios, if a question asks "How many full boxes of 12 eggs can you pack from 50 eggs?", you MUST use eggs DIV 12, resulting in 4. If you write eggs / 12, the computer calculates 4.16. You cannot pack 0.16 of a box! Standard division will lose the mark.

Check Your Understanding

1. Which programming construct involves checking a condition (like IF score == 100) and choosing which code path to execute next?

2. What would the expression 17 MOD 5 evaluate to?

3. A programmer needs a block of code to repeat exactly 50 times. Which type of iteration should they implement?

Written Exam Scenario (AO2/AO3)

Stretch (Grade 9)

"A school network requires high security. Write an algorithm that uses an iteration loop to ask the user to enter their password. If the password is 'Admin123', output 'Access Granted' and end the loop. If they enter it wrong, they must be asked again indefinitely." (6 marks)