Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Paper 2/Programming Fundamentals

Selection

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

2.2.1 Programming Fundamentals

Practise exam questions

Programming Fundamentals — Note 3 of 6

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.

What to know

  • 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.
  • In an if/elif/else chain only the FIRST true condition runs. Put the most restrictive check first (e.g. score >= 10 before score > 5), otherwise the later branches are never reached.
  • Python uses match/case for switch/case selection. OCR Exam Reference Language uses switch/case/default/endswitch for the same idea.
  • case _: is the default case. It runs when none of the other cases match, like else in an if statement.

Exam technique

  • Tip:Keywords to constructs — if = Selection, for = Iteration, while = Iteration, switch/case = SELECTION. Students commonly misidentify switch/case as iteration.
  • Tip:The three programming constructs are Sequence, Selection, and Iteration. Be able to identify which are used in a given program.
  • Tip:Boolean values can be used directly in if statements: if CheckSensorCode(sensorType) then — no need to write if CheckSensorCode(sensorType) == True then.
  • Mistake:input() returns a string, so match it with case "1":, not case 1:, unless you cast the input to int first.

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")
Selection with if / elif / else
python
score = int(input("Enter your score: "))

if score >= 10:
    print("Well done")
elif score > 5:          # only checked if the first condition was False
    print("Keep going")
else:                    # runs if no condition above was True
    print("Try again")
Switch/case selection with match
python
choice = input("Enter a number (1-3): ")

match choice:
    case "1":
        print("You chose Option 1")
    case "2":
        print("You chose Option 2")
    case "3":
        print("You chose Option 3")
    case _:  # default: runs if no other case matches
        print("Invalid choice")

Ready to test yourself?

Practise 2.2.1 questions
← Previous noteSequence2.2.1 Programming FundamentalsNext note →Iteration (count- and condition-controlled loops)2.2.1 Programming Fundamentals

Back to Programming Fundamentals

Revise another OCR GCSE topic: Data Types, Additional Programming Techniques

Programming Fundamentals

Note 3 of 6

  1. 1Variables, constants, operators, inputs, outputs and assignments
  2. 2Sequence
  3. 3Selection
  4. 4Iteration (count- and condition-controlled loops)
  5. 5Arithmetic operators
  6. 6Boolean operators AND, OR and NOT
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).