Beep! Tap the happy computer!
Coding basics

What if the steps are in the wrong order?

# Sequence and debugging ## Sequence Instructions run **in order**, top to bottom, unless you later add loops or decisions. Bad sequence for tea: 1. Drink 2. Boil water 3. Add tea leaves The computer will not say “that’s silly”. It will just do it. ## A bug A **bug** is a mistake in the instructions. **Debugging** is finding and fixing it. ## How to debug like a pro 1. Read the error message (it is a clue, not an insult) 2. Check spelling — `pirnt` is not `print` 3. Check order 4. Test a tiny piece 5. Explain the code to a rubber duck / friend > Famous truth: even expert programmers debug every day. Calm brains find bugs faster than angry brains. ## Debugging is a superpower, not a punishment Professionals spend a large part of the day finding bugs. The difference is they have a method. ### The card (copy it) 1. What did I **expect**? 2. What **happened**? 3. **Where** is the first place they disagree? 4. Change **one** thing. 5. Run again. ### Sequence bugs you will actually meet - Using a variable before you set it - Saving after you close the file - Asking for input after you already computed the answer - Drawing a page before the data arrived (web) If you can spot those in English, you will spot them in Python.

By the end of this lesson

Put steps in a working order and use a simple debug habit (what did I expect? what happened? which line?).

Remember

  • Sequence = order. Socks then shoes. Open the file then type. Boil water then add noodles.
  • A bug is a mistake in the instructions (or their order).
  • Wrong order is still a bug even if every single step looks sensible alone.
  • Debug: expected vs happened, then find the first wrong line.
  • Print / show in-between values. Do not rewrite everything in panic.

Worked examples

Cover the answer. Try the steps on paper, then open them.

Example 1 — Shoes bug

Steps: tie laces; put on shoes; pick up shoes.

  1. You cannot tie laces before the shoes are on
  2. Fix: pick up → put on → tie

Answer: order repaired

Check: Each step was fine; the sequence was not.

Example 2 — Code-shaped

print(score) then score = 5. What prints?

  1. score does not hold 5 yet
  2. You will get an error or an old value
  3. Fix: set score first, then print

Answer: assign before use

Check: Same as algebra: name the box before you open it.

Example 3 — Debug card

Program should show 8 but shows 5.

  1. Expected: 8. Happened: 5.
  2. Which line computed the number?
  3. Check that line’s inputs
  4. Fix one thing, run again

Answer: expected / happened / which line

Check: Scientists debug this way too.

Common mistakes

Slip Deleting the whole program when one line is wrong.

Fix Find the first failing step.

Smallest change that could fix it.

Slip Thinking a bug means you are “bad at computers”.

Fix Every programmer debugs daily.

It is the job, not a shame.

Slip Changing three things at once, so you cannot tell what worked.

Fix One change, then test.

Otherwise you learn nothing.

Try on paper first

Write the answer, then tap Reveal. These are not the quiz — they are warm-ups.

1. Sequence means…

Answer: The order of steps

2. A mistake in instructions is a…

Answer: Bug

3. Name the three debug questions.

Answer: Expected? Happened? Which line?

4. Put in order: eat noodles; boil water; add noodles.

Answer: boil → add → eat

Touch practice

8 tap / type

Tap or type. Use the hint if you need it. Retry any miss — the why is the lesson.

Optional picture lab

After practice

Real world

Socks after shoes — oops.

Connect

Debugging is a superpower.

⭐ Star quiz

9 questions

Do the worked examples and touch practice first. Then take the quiz without peeking.