Sequences & Instructions
Sequences in programming represent ordered sets of instructions that execute one after another, where each step can modify stored values called variables. The order of operations determines the final outcome, making sequencing a fundamental concept in computational thinking. A simple sequence might start with a value of 0 and add 3 repeatedly: 0 → 3 → 6 → 9 → 12.
Why it matters
Sequential instruction processing forms the backbone of all computer programs, from simple calculators to complex video games. Students encounter this concept in robotics classes where robots follow step-by-step commands to navigate obstacles. In financial software, sequences calculate compound interest by repeatedly applying the same formula — for example, $100 growing at 5% annually becomes $105, then $110.25, then $115.76 over 3 years. Video game engines use sequences to animate characters, updating position coordinates frame by frame at rates of 60 times per second. Understanding sequences prepares learners for programming loops, algorithm design, and mathematical induction. The concept appears in CCSS mathematical practices as students develop systematic problem-solving approaches and logical reasoning skills.
How to solve sequences & instructions
Sequences in Code
- A sequence is a set of instructions executed one after another.
- Order matters: changing the order changes the result.
- Variables store values that can be updated.
- Trace through the code line by line to find the output.
Example: x = 3, x = x + 2, print(x) → outputs 5.
Worked examples
Follow: Start at 0, add 5, add 5, add 5, add 5, add 5. What number are you at?
Answer: 25
- Execute each step → 0 -> 5 -> 10 -> 15 -> 20 -> 25 — Add 5 each time, starting from 0.
- Final value → 25 — After 5 additions of 5: 0 + 5 x 5 = 25.
Follow: Start at 1, triple, triple, triple, triple. What number?
Answer: 81
- Triple each time → 1 -> 3 -> 9 -> 27 -> 81 — Multiply by 3, 4 times.
A loop repeats 'add 4' 4 times starting from 2. Final value?
Answer: 18
- Trace the loop → 2 -> 6 -> 10 -> 14 -> 18 — Each iteration adds 4.
- Or calculate directly → 2 + 4 x 4 = 18 — Start + (step x repeats).
Common mistakes
- Executing instructions out of order produces incorrect results — following 'start at 5, multiply by 2, add 3' gives 13, but 'start at 5, add 3, multiply by 2' gives 16.
- Forgetting to update the variable after each step leads to wrong totals — when adding 4 repeatedly starting from 1, the sequence should be 1 → 5 → 9 → 13, not keeping 1 throughout.
- Counting the starting value as a step results in off-by-one errors — 'triple 4 times starting from 2' means 2 → 6 → 18 → 54 → 162, not stopping at 54.