1 / 20
Scratch Coding · Grade 5 · Chapter 4

Scratch Sequences & Repeat Loops

Mastering step-by-step algorithms and efficient repetition in visual block programming.

Learning Goals

What We'll Build Today

GOAL 1

Sequencing

Understand how computers execute code line-by-line from top to bottom.

GOAL 2

Repeat Loops

Use repeat (N) blocks to eliminate duplicate code and create animations.

GOAL 3

Forever Loops

Create continuous background actions and smooth sprite movement.

Prior Knowledge

Sequences in Real Life

Imagine tying your shoes: 1. Pull laces tight, 2. Cross them over, 3. Tie a knot. If you reverse step 1 and step 3, your shoes fall off!

Question: Why does order matter so strictly when giving instructions to a computer sprite?
Story Time

Kai's Exhausting Code

Kai wanted his Scratch sprite to take 20 steps while walking. He dragged out 20 individual move 10 steps and 20 next costume blocks! His screen was covered in 40 blocks!

His teammate showed him a special C-shaped block that reduced his script from 40 blocks to just 4. What block was it?
Core Concept

What is a Sequence?

A Sequence is an ordered set of instructions. The computer executes the first block at the top, finishes it, then moves directly to the block attached below it.

when green flag clicked
go to x: (0) y: (0)
say [Let's Dance!] for (2) seconds
play sound [DanceBeat v] until done
Execution Flow

How Scratch Executes Blocks

1

Event Trigger

when flag clicked fires and triggers the script.

2

Step 1 Execution

Sprite moves to center (0,0).

3

Step 2 Execution

Speech bubble displays "Let's Dance!" for 2 seconds.

Core Concept

What is a Repeat Loop?

A Repeat Loop is a control block that runs the instructions inside its "jaws" a specific number of times before moving to the next block.

when green flag clicked
repeat (10) {
  move (10) steps
  next costume
  wait (0.1) seconds
}
Side-by-Side Comparison

Manual Repeat vs. Loop Block

❌ MESSY MANUAL CODE

Move 10 ➔ Wait 0.1 ➔ Costume ➔ Move 10 ➔ Wait 0.1 ➔ Costume ➔ Move 10 ➔ Wait 0.1 ➔ Costume...

Hard to read, easy to make bugs, takes forever to edit!

✅ CLEAN LOOP BLOCK

repeat (3) [ move 10, wait 0.1, next costume ]

Short, elegant, easy to change repeat count from 3 to 100 instantly!

Loop Comparison

Counted Loops vs. Forever Loops

🔁 repeat (10)

Counted Loop: Runs exactly 10 times, then continues to any blocks below it.

Best for: Jumping 3 times, walking 5 steps, counting to 10.

♾️ forever

Infinite Loop: Runs continuously until the red Stop sign is pressed.

Best for: Game background music, player controls, enemy patrol.

Geometry with Loops

Drawing Shapes with Loops

To draw a 4-sided square, a sprite needs to draw a line and turn 90 degrees 4 times!

repeat (4) {
  move (100) steps
  turn right (90) degrees
  wait (0.2) seconds
}
Debunking Myths

Common Scratch Bugs

Bug: "Teleporting Sprite"

If you put move 10 steps inside a repeat loop without a wait 0.1 secs block, the computer runs it in 0.001 seconds, making it look like a warp!

Bug: "Blocks Outside the Jaw"

Putting a block under the loop instead of inside the loop means it will only run once after the loop finishes!

Smartboard Voting

Predict the Output!

Look at this script: repeat (5) [ turn right 72 degrees ]. What total rotation angle will the sprite turn?

Option A: 72 degrees
Option B: 360 degrees (a full circle!)
Vote: Thumbs UP for Option A, Thumbs DOWN for Option B!
Spot the Bug

Why Is the Dance Beat Off?

Script: repeat (10) [ play sound [Meow v] until done, change color effect by (25) ]
Problem: The cat only changes color every 2 seconds instead of flashing fast with the beat!
Discussion: What is holding up the loop execution? (Hint: check `until done` vs `start sound`!)
Think-Pair-Share

Building an Octagon

A square has 4 sides and turns 90 degrees (4 × 90 = 360). An octagon has 8 sides!

Partner Challenge: How many degrees must the sprite turn each step to draw an 8-sided octagon? (Hint: 360 ÷ 8 = ?)
Guided Practice

Step-by-Step Walking Animation

Let's build a smooth walking animation on the smartboard!

1. when green flag clicked
2. go to x: (-180) y: (0)
3. repeat (36) {
    move (10) steps
    next costume
    wait (0.05) seconds
}
Hands-on Challenge

The Rainbow Spin Challenge

Mission: Create a Scratch script that makes your sprite grow bigger, change color, and spin 360 degrees, then return to normal size!
Scratch Task: Combine change size by (5) and turn right (15) inside a repeat loop!
Quick Check · Question 1

How many total steps will a sprite move with this code: repeat (4) [ move (10) steps ]?

A10 steps
B14 steps
C40 steps
D400 steps
Click to reveal answer
Quick Check · Question 2

What happens to code placed inside a forever loop block?

AIt runs only 1 time and stops
BIt runs 10 times and pauses
CIt repeats continuously until the program is stopped
DIt deletes the sprite
Click to reveal answer
Summary

Chapter 4 Key Takeaways

Looking Ahead

Next Chapter: Conditionals!

What if we want our sprite to make decisions? "IF touching key, THEN collect gem!" We'll unlock Scratch Conditionals next!

Exit Ticket: Draw a block diagram on paper showing a repeat loop that flashes a light 5 times!