Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Supplementary programming practice/Selection

IF and Else

301.9 Selection

Practise exam questions

Selection — Note 1 of 4

Choose between two paths.

What you need to know

An if statement checks a condition — if True, the indented block runs. An optional else block runs when the condition is False. This lets the program choose between two paths.

What to know

  • if condition: runs block when True
  • else: runs when the condition is False
  • The condition must be a Boolean expression
  • Only one branch executes — never both

Code examples

IF and Else
python
age = int(input("Age: "))
if age >= 18:
    print("Adult")
else:
    print("Minor")
← Previous topicTranslate logic301.8 Boolean ExpressionsNext note →ELIF chains301.9 Selection

Back to Selection

Specification notes for programming are in Paper 2.

Selection

Note 1 of 4

  1. 1IF and Else
  2. 2ELIF chains
  3. 3Nested IF
  4. 4Match Case
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).