KS3 · Computer Science

Sequencing instructions in Scratch

Imagine an ATM that checks your PIN before you have typed one. A computer would do exactly that if you wrote the steps in that order.

Computer Science · Programming

A vending machine, one line at a time

The opening lines of a vending machine program, written in Python. The prices are example amounts in coins. Press next and watch which line runs, and what changes.

Before you press next: which line do you think runs straight after drink_price = 4?

1 chocolate_price = 3
2 crisps_price = 2
3 drink_price = 4
4 print("Chocolate costs", chocolate_price)
5 print("Crisps cost", crisps_price)
6 print("Drink costs", drink_price)
7 print("Enter your choice")
8 choice = input()
chocolate_pricecrisps_pricedrink_pricechoice
3

Output

 

Step 1: Line 1 runs first, and only line 1. chocolate_price now holds 3. Look at the other boxes: still blank. Those lines have not run yet.

1 / 8

Step through the trace — every value is the lesson’s, not run by the page.

Step 1 of 8: Line 1 runs first, and only line 1. chocolate_price now holds 3. Look at the other boxes: still blank. Those lines have not run yet..

Watch out: A blank box means that line has not run yet. It does not mean zero.

Computer Science · Sequence

What does the computer do with your lines?

You have just watched the vending machine program run. Think about how the computer decided which line came next.

Which of these is closest to what you think right now?
How sure are you?

Computer Science · Sequence

Put the ATM program in order

the order the ATM program runs its steps

1 · Runs first4 · Runs last
  1. Check the PIN

  2. Output "Access Granted" if the PIN is correct, or "Access Denied" if it is wrong

  3. Welcome the user

  4. Ask the user to enter the PIN

Computer Science · Sequence

The same opening lines, as a flow chart

Same program, drawn as symbols. Step through and notice there is only one way to go.

Which symbol runs straight after "crisps_price = 2"?

chocolate_price = 3crisps_price = 2drink_price = 4Print the three pricesPrint "Enter your choice"choice = input()
chocolate_price=3

Output

 

Step 1: Start at the first symbol. chocolate_price is set to 3.

1 / 6

Step through the trace — every value is the lesson’s, not run by the page.

Step 1 of 6: Start at the first symbol. chocolate_price is set to 3..

Computer Science · Control structures

Sequence, selection or iteration?

Which control structure does each description show?

Still to sort

Sequence (0)

Instructions run in the order they appear, one after another.

Where the line is: Nothing here chooses a path or repeats lines. It just carries on to the next instruction.

Selection (0)

More than one path to follow, picked by whether a condition is True or False.

Where the line is: Selection needs a True or False condition and more than one path. Sequence has no such choice.

Iteration (0)

Also called looping: the same lines run more than once.

Where the line is: Iteration repeats the same lines. Sequence just moves on down the program.

6 of 6 still to sort.

Programs are built from three main control structures. Decide which one each description shows, in code and in flow charts.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

The computer never guesses what you meant to do first.

What you need to know

  • Sequence is the order of commands in a program. Instructions run in the order they appear in the code, one after another.
  • The computer does not guess what you meant, so the programmer has to put the instructions in the right order.
  • The three main control structures are sequence, selection and iteration.
  • In a flow chart, sequence is symbols running one after another. Selection is a decision symbol with True and False coming off it.

The big picture

Sequence is the order of commands in a program: instructions run in the order they appear in the code, one after another. It is one of the three main programming control structures, alongside selection and iteration, and the three can be combined to build more complex programs.

Key points

1Sequence: instructions run in the order they appear, one after another.
2Selection: more than one path to follow, picked by whether a condition is True or False (an if statement is an example).
3Iteration (looping): the same lines of code run more than once (a while loop is an example).
4Sequence, selection and iteration can be combined to create more complex programs.

Worked example

Problem

Here is a short program. When it runs, the user types 2 when asked. In what order do the two things on the screen appear, and what is stored in tickets? 1 ticket_price = 5 2 print("Ticket price:", ticket_price) 3 print("How many tickets?") 4 tickets = input()

⚠ Watch out

Thinking the computer will fix a muddled order for you, or run all the lines at once. It does neither. It runs the lines in the order you wrote them, one after another.

🧠

Memory hook

Computers follow, they don’t guess: top to bottom, one line after another.

✓

Check yourself

Without looking back: write one sentence explaining what sequence means, then say which control structure a decision symbol with True and False coming off it shows.

Flashcards

(10)
What is sequence in a program?
The order of commands in a program: instructions run in the order they appear in the code, one after another.
Name the three main programming control structures.
Sequence, selection and iteration.
You write your instructions in the wrong order. What does the computer do?
It still runs them in the order you wrote them. It does not guess what you meant, so the programmer has to put them in the right order.
How does a flow chart show sequence?
As a number of symbols running one after another.
How does a flow chart show selection?
As a decision symbol with True and False coming off it.
What is selection? Give an example.
Used when there is more than one path for the program to follow: code runs based on whether a condition is True or False. An if statement is an example.
What is iteration? Give an example.
Also known as looping: it lets you run the same lines of code more than once. A while loop is an example.
Can a program use more than one control structure?
Yes. Sequence, selection and iteration can be combined to create more complex programs.
What order does the ATM program run its steps in?
Welcome the user, ask for the PIN, check the PIN, then output "Access Granted" if it is correct or "Access Denied" if it is wrong.
In the vending machine program, what comes before the prices are printed?
Three variables (chocolate_price, crisps_price and drink_price) are assigned their amounts in coins. After the prices are printed, "Enter your choice" is printed and the input is stored in choice.

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 KS3 Computer Science topics

See the full KS3 Computer Science curriculum →

How this lesson was checked. This KS3 Computer Sciencelesson 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.