GCSE · Computer Science · Edexcel · Spec 1CP2
Sequence
Picture a quiz that says "Well done!" before it has asked you a single question. Nothing is missing. Every line the program needs is there. So what went wrong?
Computer Science · Sequence
Same three lines, two orders
Step through the program one line at a time. Watch the user column: it tells you what the computer has stored so far.
Before you step through Order B: the welcome line wants to show user. Has anything been stored in user yet?
1 # ORDER A: question, input, welcome2 print("What is your name?")3 user = input()4 print("Welcome", user)5 # ORDER B: the same three lines, welcome first6 print("Welcome", user)7 print("What is your name?")8 user = input()
| user |
|---|
| — |
Output
What is your name?
Step 1: Order A, line 1. The question appears on the screen. Nothing is stored in user yet, and that is fine, because nothing needs it yet.
Press Next to run one line at a time. The lines that run are the ones the computer is told to run, in the order it is told to run them.
Computer Science · Logic errors
Which sequence mistake is it?
Sort each snippet into the kind of sequence mistake it shows.
Still to sort
Displaying something before setting it (0)
The line that gives the value comes after the line that shows it.
Printing output before processing the data (0)
The line that works the answer out comes after the line that prints it.
Asking for input after trying to use it (0)
The line that takes the input comes after the line that uses it.
Each snippet has exactly one thing wrong. Pick a snippet, then pick the kind of mistake.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Same lines, different order, different result.
What you need to know
- Sequence is the order of the commands in a program.
- A program runs from top to bottom, executing each line in turn, one statement at a time.
Have a goA program has five lines. The computer has just finished line 2. What does it do next?
It runs line 3.
The program runs from top to bottom, one line at a time, so the next line down is the next to run.
- In a program of print statements, the output appears in the same order as the instructions.
- Computers execute instructions exactly as given, so a different order means different steps and different output.
Have a goJo says: "I tidied your program by shuffling the lines around. They are all still there, so it will do the same thing." Will it?
Not safely. Changing the order changes the steps, so the output changes.
The computer does exactly what it is given in the order it is given, so keeping every line is not the same as keeping the program.
- Having all the necessary lines is not enough if they are in the wrong order.
- A program that runs but shows its messages in the wrong order contains a logic error.
- Common sequence mistakes: displaying something before setting it, printing before processing the data, asking for input after trying to use it.
- A welcome message that shows user must come after the input is stored in user. Printing it first results in an error.
- Debugging is finding and fixing errors, and spotting a wrong sequence of instructions is an important part of it.
Have a goYour program runs to the end but its messages come out in the wrong order. Is there anything left to debug?
Yes. It has a logic error to find and fix.
Errors can stop a program running or make it give the wrong output, and debugging covers both.
The big picture
A program runs its lines from top to bottom, one at a time, exactly as they are written. So the order is part of the program: the right lines in the wrong order give unexpected or incorrect results, which is a logic error. Spotting a wrong sequence is an important part of debugging.
Key points
Worked example
Problem
A countdown program should show 3, then 2, then 1, then Lift off! on the screen, in that order. It has all four lines, but they are written as: print("Lift off!"), print(2), print(3), print(1). Put the lines in the right order.
⚠ Watch out
Thinking that a program with every necessary line will work whatever their order. The computer does exactly what it is told, in the order it is told, so a wrong order changes the steps and the output.
Memory hook
Top to bottom, exactly as told. The computer never reorders for you.
Check yourself
Line 1 is print("Bye") and line 2 is print("Hi"), but the programmer wanted Hi first. What shows first, and what is the fix? Answer: Bye shows first. Put the lines in the correct order.
Flashcards
(12)What is sequence in a program?
In what order does a program run its lines?
In a program of print statements, how is the output ordered?
Why does changing the order of lines change the output?
If a program has every line it needs, will it work?
What do instructions in the wrong order produce?
What is a logic error caused by wrong order?
Name the three common sequence mistakes.
Why must a welcome message that shows user come after the input?
What is the correct sequence for the welcome program?
What is debugging?
What can errors do to a program?
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
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 9 October 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.