GCSE · Computer Science · Edexcel · Spec 1CP2
Programming – sequencing
You press start and the game says Level completed before it has even begun. The computer is not broken. It did exactly what it was told.
Computer Science · Sequence
Run it. Then reorder it.
Step through a game's start-up messages, one line at a time, and watch the output build underneath.
Before you press Next: which message do you think appears first?
1 print("Level completed")2 print("Get ready")3 print("Game started")4 # same three lines, new order5 print("Get ready")6 print("Game started")7 print("Level completed")
Variables
Output
Level completed
Step 1: Line 1 runs first, simply because it is at the top. Out comes Level completed. The game has not even started yet.
Press Next to run one line at a time. Every step shown here is written out by the lesson; the page does not run the code.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Same lines, different order, different program.
What you need to know
- Sequence is the order of commands in a program.
- A program performs its instructions from top to bottom, one line at a time.
- In Python, code runs line by line unless something, such as repeating steps or making decisions, changes the order.
- Output appears in the same order as the instructions: four print statements give line 1 to line 4, in that order.
Have a goA program has print("A"), then print("B"), then print("C"), in that order. What does the screen show, from first to last?
A, then B, then C.
Output follows the order of the instructions, so the first line written is the first line shown.
- Computers execute instructions exactly as given, so precise instructions in the correct sequence matter.
- Change the sequence and you change the steps the computer takes, so the output changes.
Have a goYour friend says you can swap two print lines and the output stays the same, because the computer works out what you meant. Swap print("Get ready") and print("Game started"). What does your friend actually get?
Game started first, then Get ready.
The computer does not work out what you meant; it follows the lines exactly as written, so a new order gives a new output.
- A logic error is when a program runs but produces an incorrect result.
Have a goPriya says: "My program ran all the way to the end, so it cannot have a logic error." What has Priya missed?
A logic error is a program that runs but gives an incorrect result.
Running to the end does not make the result correct. A logic error is about the result, not about whether the program runs.
- Incorrect sequencing causes logic errors, such as displaying something before setting it or printing output before processing the data.
- A welcome message that uses user before the line that takes the input will not work until the sequence is corrected.
- Debugging is finding and fixing errors in code, and spotting an incorrect sequence of instructions is an important part of it.
The big picture
A program runs its instructions from top to bottom, so the order of the lines decides the order of the output. Incorrect sequencing causes logic errors, where the program runs but gives an incorrect result, and debugging includes putting the instructions into the correct sequence.
Key points
Worked example
Problem
This program should print the steps of a morning routine in this order: Wake up, Eat breakfast, Get dressed, Leave for school. Here is the code: 1 print("Wake up") 2 print("Leave for school") 3 print("Eat breakfast") 4 print("Get dressed") What does it output, and how do you fix it?
⚠ Watch out
Expecting the computer to work out what you meant. It runs the lines exactly as written, and a wrong order can run happily and still give an incorrect result.
Memory hook
Exactly as told, top to bottom: change the order, change the output.
Check yourself
Cover the page. A program prints three messages in the wrong order and runs to the end. Say what kind of error this is, what caused it, and how you would fix it.
Flashcards
(10)What is sequence in programming?
In which direction does a Python program run its instructions?
Four print statements are written as line 1 to line 4. In what order does their output appear?
Why do precise instructions in the correct sequence matter?
What happens to the output if you change the sequence of the code?
What is a logic error?
Give two examples of a sequencing logic error.
What is the correct sequence for the welcome program that uses the variable user?
What is debugging?
What is an important part of debugging a sequencing error?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Edexcel GCSE Computer Science topics
- Identifying and correcting program errors
- Primitive data types
- Programming – condition-controlled repetition
- Programming – count-controlled repetition
- Programming – iteration over data structures
- Programming – selection
- Programming arithmetic operators
- Programming logical operators
- Programming relational operators
- Reading, writing, analysing and refining programs
- Single entry/exit code blocks
- String manipulation
How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 21 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.