GCSE · Computer Science · Eduqas · Spec C500QS
Sequence in programs
Swap two lines of a program and the computer will not guess what you meant. It just does what the new order says.
Computer Science · Sequence
Call each line before it runs
A program runs top to bottom, one line at a time. Step through it, and call each output before the program shows it.
Press Next to run a line. At each stop, make your call before the program shows you.
points = 10print("Points:", points)points = points + 5print("Points:", points)
Variables
Step 1. Line 1 runs first. points now holds 10. Nothing is printed yet.
Ask at every line: what has already happened, and what does this line use?
Computer Science · Sequence
Which sequence mistake is it?
Tap a snippet, then tap the mistake it shows.
Still to sort
Displaying something before setting it (0)
The print comes before the line that gives the variable the value you wanted to show.
Where the line is: The late line gives the variable a value directly.
Printing output before processing the data (0)
The print comes before the line that works the result out from stored data.
Where the line is: The late line works something out from values that are already stored.
Asking for input after trying to use it (0)
The line that uses the answer runs before the line that asks for it.
Where the line is: The late line is the one that asks the user.
Each snippet lists its lines from top to bottom, separated by ' / '. All of them run and print something wrong.
Computer Science · Sequence
Run it, check it, fix it
This program should print Area: 12 for a rectangle 4 wide and 3 high. Press Run, compare what it prints with what you expected, then fix the flagged line. Repeat until it is right.
Each choice rewrites one line. Swapping two lines takes two edits: write the line where it belongs, then replace its old copy.
- width = 4
- height = 3
- area = 0
- print("Area:", area)
- area = width * height
The outputs are what Python 3 prints for this exact code.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
The computer does exactly what you wrote, in the order you wrote it.
What you need to know
- A program is performed from top to bottom, executing each line in turn. That order is its sequence.
Have a goYour mate Sam swears the computer saves the best line for last, so it runs the bottom line first. Which line does it really run first?
The top line.
Sam has the order upside down: a program is performed from top to bottom, so the first line goes first.
- Computers execute instructions sequentially to produce output: one statement at a time, in the order they are written.
- When the instructions are print statements, the output appears in the same order as the instructions.
Have a goA program's lines, top to bottom: print("sun"), print("moon"), print("star"). You swap the first and last lines. What does the screen show, first to last?
star, moon, sun
Output appears in the same order as the print instructions, so swapping the lines swaps the output.
- Computers execute instructions exactly as given, so you have to give precise instructions.
- Change the sequence and you change the steps the computer takes, which changes the output.
Have a goA program's lines, top to bottom: x = 2, then print(x), then x = x + 3. What does it print?
2
The print runs before x = x + 3, so x still holds 2. The update happens afterwards, which is why the order changes the output.
- Instructions in the wrong order give unexpected or incorrect results. The program only follows what we provide.
- A program that does the wrong thing because its lines are in the wrong order has a logic error.
- Common sequence logic errors: displaying something before setting it, printing before processing the data, asking for input after using it.
- Debugging is finding and fixing errors in a program. Spotting the incorrect sequence is an important part.
- Fix a wrong sequence by reordering: take the input and store it in a variable before the line that uses it.
The big picture
A program runs one line at a time, in the order the lines are written, so the order decides the steps the computer takes and the output you get. Lines in the wrong order give a logic error, and debugging means finding and fixing it.
Key points
Worked example
Problem
Work out exactly what this program prints, in order: cups = 3 print(cups) cups = cups + 2 print(cups * 2)
⚠ Watch out
Thinking the computer will work out what you meant, or that the order does not matter as long as every line is there. It follows the lines exactly as given, so lines in the wrong order make it do the wrong thing. That is a logic error.
Memory hook
The computer is not guessing, it is reading. One line at a time, in the order you wrote them.
Check yourself
Cover the code. A program has lives = 3, then print(lives), then lives = lives - 1. Say what it prints and why. Then say which line has to move for it to show 2.
Flashcards
(11)What does 'sequence' mean in a program?
In what order does print output appear?
Why do programs need precise instructions?
You change the sequence of a program. What changes?
What is a logic error in sequence?
Name the three common sequence mistakes.
A print sits above the line that updates a variable. What does it show?
The line that uses the user's input comes before the line that asks for it. What goes wrong?
What is debugging?
How do you correct a wrongly sequenced program?
A program prints an old value you thought you had changed. What should you check first?
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 Eduqas GCSE Computer Science topics
- Mathematical and logical operations in code
- Modular structuring with abstraction
- Presenting test outcomes with commentary
- Program a solution to requirements
- Refining code during development
- Selection in programs
- String manipulation in code
- Subroutines with well-defined interfaces
- Typical, extreme and erroneous test data
- Understanding revised requirements
- Using a variety of data types
- Using testing outcomes to inform development
How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)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 16 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.