🔢 Sequence: Order Matters

3rd Grade 💻 Coding

Socks first, then shoes — not the other way around. In programming, too, order is everything. The first idea every programmer learns is called sequence: the computer carries out instructions one after another, in exactly the order they were written. In this lesson we see why that matters and what happens when things get mixed up.

Free · US Letter · no sign-up
Google Classroom Save to Pinterest Email me

One after another

When a computer runs a program, it starts with the first instruction, carries it out, moves on to the second, carries that out, and so on until the end. In a written language like Python, it reads from top to bottom, line after line. In Scratch, it runs the blocks in the order they’re snapped together, from the top block to the bottom one.

That sounds simple, but it means the computer doesn’t “look ahead” and doesn’t understand what the goal is. If we wrote “show the result” before “calculate the result,” it will show something empty or old, and only afterward do the calculation. A person would realize that’s a mistake and switch the order. A computer won’t.

Examples from real life

Making a glass of chocolate milk is a sequence: get a glass, pour in milk, add chocolate powder, stir and drink. If we switch the order and stir before there’s milk in the glass, the spoon just spins in the air. If we drink before adding the chocolate, we get plain milk. Every step builds on the step before it.

Your morning has a sequence too: get up, brush your teeth, get dressed, eat and head out. For some of the steps, the order doesn’t matter much — you can get dressed before or after you brush your teeth. But for some it’s critical: you can’t put on your shoes before your socks, and you can’t leave the house before you get up. Good programmers keep asking: which step has to come before which?

Sequence in code

Here are three lines of Python. The first line, name = "Mia", stores the name Mia. The second line, print("Hello " + name), shows “Hello Mia.” The third line, print("Bye"), shows “Bye.” The result on the screen: first “Hello Mia” and then “Bye” — exactly in the order of the lines.

Now let’s swap the first two lines: first we try to show the name, and only then do we store it. The computer reaches the line that shows name before anyone has told it what name is, and it stops with an error message. The exact same lines in a different order — and a program that doesn’t work. Scratch is similar: if the sprite “says hello” before it “goes to the center of the stage,” it will talk while it’s still in the corner.

How to plan a sequence that works

Before you write code, it helps to write the steps in plain English and number them. Then “run it in your head”: go through the list as if you were the computer, step by step, and check that each step can actually happen — that it has everything it needs from the steps before it. This check is called tracing, and experienced programmers do it all the time.

One more tip: when a program doesn’t do what you wanted, one of the first questions to ask is “Maybe the order is wrong?” Lots of beginner bugs are simply two lines that got swapped. As programs grow, sequence stays the foundation — even conditions and loops, which we’ll learn next, are really just clever ways of changing the sequence.

For example

  • Socks first, then shoes — a sequence you can’t swap.
  • In Scratch, if “say Hello” comes before “go to the center,” the sprite talks in the corner and only then moves.
  • In Python, if you show the result before you calculate it, the computer shows an old value or stops with an error — because it simply follows the order.

Key facts

  • Sequence means the computer carries out instructions one after another, in the order they were written.
  • In Python, code is read from top to bottom; in Scratch, from the top block to the bottom one.
  • The same instructions in a different order can give a different result — or an error.
  • Tracing is “running the program in your head,” step by step, to check it.
  • Lots of beginner bugs are just two lines that got swapped.

📌 Remember: Sequence = one step after another. The order decides what happens.

Quick quiz

  1. What does sequence mean in programming?

  2. In what direction does the computer read Python code?

  3. What happens if you try to show a variable before you’ve stored a value in it?

  4. Which step has to come before “put on your shoes”?

  5. What is tracing (“running it in your head”)?

  6. In Scratch, in what order do snapped-together blocks run?

  7. What’s a good question to ask when a program does something unexpected?

  8. Making chocolate milk: what happens if you stir before there’s milk in the glass?

  9. What can happen if you swap the order of two instructions?

💭 Think and talk about it

  1. Find two steps in your morning where the order doesn’t matter, and two that have to happen in a certain order.
  2. Why do you think a computer doesn’t “fix” a wrong order by itself, the way a person would?
  3. Write a five-step sequence for planting a seed in a pot. What happens if you swap the second and fourth steps?

Questions kids ask

Does a computer always carry out instructions in order?

The default is sequence — in order. Conditions and loops change that: a condition can skip instructions, and a loop can jump back and run instructions again. But even then, each part runs in order.

What is “program flow”?

It’s the path the computer takes through the code: which instruction runs after which. In a simple sequence the flow goes straight from top to bottom; conditions and loops create branches and repeats.

How can you practice sequence without a computer?

Cut the steps of a recipe or a story into cards, shuffle them and put them back in order. Then check what happens if you swap two cards — does it still make sense?

🔎 Ask Thinkapedia another question