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 order
5 print("Get ready")
6 print("Game started")
7 print("Level completed")

Variables

lines run in this run=1

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.

1 / 7

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.

Step 1 of 7: Line 1 runs first, simply because it is at the top. Out comes Level completed. The game has not even started yet..

Exam line: Output comes out in the order of the instructions. Change the order and you change the output.
Watch out: A wrong order does not have to stop the program. The first run finished happily and still gave the wrong result.

Computer Science · Logic errors

So what just went wrong?

The game printed Level completed, then Get ready, then Game started. Every line ran. Nothing crashed.

Which idea is closest to what you think?
How sure are you?

Computer Science · Fixing a sequence

Put the welcome program in order

the order the computer must run these three lines for the welcome program to work

1 · Runs first3 · Runs last
  1. print("Welcome", user)

  2. print("What is your name?")

  3. user = input()

Exam line: A line that uses user must come after the line that sets user.

Computer Science · Debugging

Hunt the out-of-order line

This program should print the total cost of 3 items that cost 4 each. It prints Total: 0 instead of Total: 12. Which line is out of sequence?

A student's program — which line goes wrong?

Exam line: For a sequencing bug, check that each line runs after the lines it depends on.

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

1The computer follows the order of the lines, so the output appears in the same order as the instructions.
2Changing the sequence changes the steps taken, and so changes the output.
3Incorrect sequencing causes logic errors: the program runs, but the result is incorrect.
4Debugging includes finding the instruction that is out of place and putting the code into the correct sequence.

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?
The order of the commands in a program.
In which direction does a Python program run its instructions?
Top to bottom, one line at a time, unless something such as repeating steps or making decisions changes the order.
Four print statements are written as line 1 to line 4. In what order does their output appear?
Line 1 to line 4, in that order: the output follows the order of the instructions.
Why do precise instructions in the correct sequence matter?
Computers execute instructions exactly as they are given, so instructions in the wrong order produce unexpected or incorrect results.
What happens to the output if you change the sequence of the code?
The steps the computer takes change, so the output changes too.
What is a logic error?
A program that runs but produces an incorrect result.
Give two examples of a sequencing logic error.
Any two of: displaying something before setting it; printing output before processing the data; showing messages in the wrong order.
What is the correct sequence for the welcome program that uses the variable user?
Print the question, take the input and store it in user, then print the welcome message.
What is debugging?
The process of finding and fixing errors in program code.
What is an important part of debugging a sequencing error?
Identifying the incorrect sequence of instructions, so the code runs in the correct sequence and produces the desired result.

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 posted

More Edexcel GCSE Computer Science topics

See the full Edexcel Computer Science curriculum →

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.