Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Programming Fundamentals

The use of the three basic programming constructs used to control the flow of a program: Selection

All topicsPractise exam questions
Knowledge organiser

Programming Fundamentals

2.2.1c

Practical use of the techniques, Understanding of each technique

What you need to know

Selection allows a program to make decisions and choose different paths based on a condition. The most common forms are IF-THEN-ELSE statements and SWITCH/CASE SELECT statements. A condition is evaluated as True or False, and the program executes different code depending on the result.

Key points

  • Selection uses conditions to decide which code to execute (decision-making).
  • IF-THEN executes code only when the condition is True.
  • IF-THEN-ELSE provides an alternative path when the condition is False.
  • ELSEIF (or elif in Python) allows multiple conditions to be checked in sequence.
  • SWITCH/CASE SELECT checks a variable against multiple possible values — this is SELECTION, not iteration.
  • Conditions use comparison operators (==, !=, <, >, <=, >=) and Boolean operators (AND, OR, NOT).
  • Selection can be nested: an if statement inside another if statement.
  • Exam Tip:Keywords to constructs — if = Selection, for = Iteration, while = Iteration, switch/case = SELECTION. Students commonly misidentify switch/case as iteration.
  • Exam Tip:The three programming constructs are Sequence, Selection, and Iteration. Be able to identify which are used in a given program.
  • Exam Tip:Boolean values can be used directly in if statements: if CheckSensorCode(sensorType) then — no need to write if CheckSensorCode(sensorType) == True then.

Code examples

Selection: if/elif/else
python
score = int(input("Enter your score: "))

if score >= 70:
    print("Distinction")
elif score >= 50:
    print("Merit")
elif score >= 40:
    print("Pass")
else:
    print("Fail")