2.6 Actions

2.6.1 Sequence

Sequence
Definition: Sequence is when instructions are executed one after another in order.

Purpose: To ensure steps happen in the correct order.

When used: In all programs where actions must follow a logic flow.

Python example:

print("Start program")
x = 5
y = 10
total = x + y
print(total)
        

2.6.2 Selection

Selection (if / elif / else / match-case)
Definition: Selection allows different actions based on conditions.

Purpose: Decision‑making in programs.

When used: When different outcomes are needed.

Python example (if / elif / else):

score = 65

if score >= 70:
    print("Distinction")
elif score >= 50:
    print("Pass")
else:
    print("Fail")
        
Python example (match / case):

day = "Monday"

match day:
    case "Monday":
        print("Start of week")
    case "Friday":
        print("End of week")
    case _:
        print("Midweek")
        

2.6.3 & 2.6.4 Loops and Iteration

Loops (Iteration)
Definition: Loops repeat actions while a condition is met.

Types:
  • Count‑controlled loops (for)
  • Condition‑controlled loops (while)
For loop example:

for i in range(1, 6):
    print(i)
        
While loop example:

count = 1

while count <= 5:
    print(count)
    count += 1
        
Benefits and Drawbacks of Loops
Benefits:
  • Reduce repeated code
  • Improve efficiency
  • Handle large datasets easily
Drawbacks:
  • Infinite loops if conditions are incorrect
  • Logic errors if misused

2.6.6 Interpreting code using actions

Interpreting Code
Interpreting code means understanding what it will do.

Example:

total = 0

for i in range(3):
    total += i

print(total)
        
This loop adds 0, 1, and 2.

2.6.7 Developing code using actions

Developing Code
Python example:

number = int(input("Enter a number: "))

if number % 2 == 0:
    print("Even")
else:
    print("Odd")
        

2.6.8 Debugging code using actions

Debugging Code
Incorrect code:

count = 1

while count <= 5:
print(count)
count += 1
        
Problems:
  • Indentation error
  • Loop body incorrectly structured
Corrected code:

count = 1

while count <= 5:
    print(count)
    count += 1