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

Knowledge organisers / Output and Sequence

Sequence execution

All topicsPractise exam questions
Knowledge organiser

Output and Sequence

301.1c

Predict order that statements run.

What you need to know

Python executes statements from top to bottom, one at a time. The order matters — using a variable before it is assigned causes an error.

Key points

  • Code runs line by line, top to bottom
  • Each line finishes before the next starts
  • If you reassign a variable, only the new value is used after that point
  • Moving a line changes the program's behaviour

Code examples

Sequence matters
python
x = 5
x = x + 1
print(x)  # 6, not 5

# Swapping order would give a different result