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 = 10
print("Points:", points)
points = points + 5
print("Points:", points)

Variables

points=10

Step 1. Line 1 runs first. points now holds 10. Nothing is printed yet.

Step 1 of 4Called right: 0 of 3

Ask at every line: what has already happened, and what does this line use?

Computer Science · Sequence

Put the program back in order

When the computer should run each line to greet the user by name

1 · Runs first3 · Runs last
  1. message = "Hello, " + name

    Works out the greeting from the stored name.

  2. print(message)

    Displays the result.

  3. name = input("Your name? ")

    Asks the user and stores what they type.

Exam line: Each line has to come after the line it depends on: store the input, then use it, then show the result.

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.

6 of 6 still to sort.

Each snippet lists its lines from top to bottom, separated by ' / '. All of them run and print something wrong.

Exam line: Name the mistake by what runs too early: a display before the value is set, a print before the data is processed, or input asked for after it was used.
Watch out: Here every variable already holds an older value, so each program runs and prints the wrong thing. A variable that has never been set at all makes Python stop with an error instead, which is a different kind of problem.

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.

Python
  1. width = 4
  2. height = 3
  3. area = 0
  4. print("Area:", area)
  5. area = width * height

The outputs are what Python 3 prints for this exact code.

Computer Science · Sequence

What will the computer do?

A program has every line it needs, but two of the lines are in the wrong order.

Which is closest to what you think the computer will do?
How sure are you?

Exam line: The computer executes instructions exactly as they are given, so lines in the wrong order make it do the wrong thing.

Computer Science · Exam practice

Explain how the order changes the output

Version A: stock = 20 stock = stock - 5 print(stock) Version B: stock = 20 print(stock) stock = stock - 5

Both versions below are meant to print the stock left after 5 items are sold. Explain how the sequence of a program affects the output it produces. Use the two versions in your answer. [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

Exam line: Name what the computer does, say what changes when the order changes, give the two outputs, and name the mistake.

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

1A program runs one line at a time in the order the lines are written.
2A print shows the value a variable holds at the moment the print runs.
3Changing the sequence changes the steps, and so the output.
4Lines in the wrong order give a logic error: the program does the wrong thing, exactly as instructed.
5Debugging a sequence error means spotting the wrong order, then putting the instructions in the right one.

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?
The order the instructions are written in. The computer runs them top to bottom, one line at a time.
In what order does print output appear?
In the same order as the print instructions in the program.
Why do programs need precise instructions?
Computers execute instructions exactly as they are given.
You change the sequence of a program. What changes?
The steps the computer takes, and so the output.
What is a logic error in sequence?
Instructions in the wrong order make the program do the wrong thing or give an incorrect result. That is called a logic error.
Name the three common sequence mistakes.
Displaying something before setting it; printing output before processing the data; asking for user input after trying to use it.
A print sits above the line that updates a variable. What does it show?
The earlier value, because the update has not run yet when the print runs.
The line that uses the user's input comes before the line that asks for it. What goes wrong?
The using line runs first, so it does not use what the user typed.
What is debugging?
Finding and fixing errors in a program. Spotting the incorrect sequence of instructions is an important part of it.
How do you correct a wrongly sequenced program?
Put the instructions in the right order, for example store the user's input in a variable before the statement that uses it.
A program prints an old value you thought you had changed. What should you check first?
Whether a print sits above the line that updates the value.

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 Eduqas GCSE Computer Science topics

See the full Eduqas Computer Science curriculum →

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.