Lesson 4: Patterns in Scratch
About 15-20 minutes -- Computer lesson
What You Will Learn
By the end of this lesson, you will be able to:
- Use the "repeat" block to make instructions run multiple times
- Create a square using a repeat loop
- Use the pen and stamp tools to leave visual trails
- Make geometric art by combining repeat blocks with turning and color changes
The Repeat Block
In Lesson 3, you learned that a loop repeats instructions. Now it is time to use a real loop in Scratch! The repeat block is one of the most powerful blocks in Scratch.
Step-by-Step: Find the Repeat Block
- Open Scratch at scratch.mit.edu and click "Create."
- In the Blocks Palette on the left, click on the "Control" category. It is orange.
- Find the block that says "repeat 10". It has a special shape -- it wraps around other blocks like a mouth.
- Drag it into the Coding Area. Notice the opening in the middle where other blocks can go inside.
Repeat Block: A Scratch block that runs the blocks inside it a set number of times. The number tells it how many times to repeat. You can change this number to any amount you want.
Step-by-Step: Your First Loop
- Drag a "when green flag clicked" block from Events into the Coding Area.
- Snap a "repeat 10" block from Control below it.
- From Motion, drag a "move 10 steps" block and put it INSIDE the repeat block (in the mouth-shaped opening).
- Click the green flag. The cat moves 10 steps, 10 times -- that is 100 steps total!
You just used one "move" block to make the cat move 100 steps. Without the repeat block, you would need 10 separate "move" blocks. That is the power of loops!
Talk About It
Ask your child: "How is the repeat block like what we talked about in Lesson 3? Remember the Robot Game -- instead of saying STEP FORWARD ten times, you can say REPEAT 10 TIMES: STEP FORWARD. The repeat block does exactly that!"
Drawing with the Pen
To see patterns on the stage, we need a way to draw. Scratch has a special set of blocks called "Pen" that let sprites draw lines as they move, like holding a marker on paper.
Step-by-Step: Add the Pen Extension
- Click the blue "Add Extension" button in the bottom-left corner of the screen (it looks like a block with a plus sign).
- Click on "Pen" from the list of extensions.
- New green pen blocks will appear in your Blocks Palette!
Step-by-Step: Draw a Line
- Start with a "when green flag clicked" block.
- Add an "erase all" block from Pen (this clears old drawings).
- Add a "pen down" block from Pen (this puts the pen on the paper).
- Add a "move 100 steps" block from Motion.
- Click the green flag. The cat draws a line as it moves!
"Pen down" means the sprite will draw wherever it goes. "Pen up" means the sprite moves without drawing (like lifting a marker off the paper).
Drawing a Square with a Loop
Now let us combine the repeat block with the pen to draw a shape. Think about what a square is: four sides, all the same length, with a 90-degree turn between each side. That sounds like a pattern!
The Pattern in a Square
To draw a square, you do this:
- Move forward
- Turn right 90 degrees
- Move forward
- Turn right 90 degrees
- Move forward
- Turn right 90 degrees
- Move forward
- Turn right 90 degrees
See the pattern? "Move forward, turn right 90 degrees" repeats 4 times. That means we can use a loop!
Step-by-Step: Draw a Square
- Start with "when green flag clicked"
- Add "erase all" from Pen
- Add "pen down" from Pen
- Add "repeat 4" from Control (change the number from 10 to 4)
- INSIDE the repeat block, add "move 100 steps" from Motion
- INSIDE the repeat block, below "move," add "turn right 90 degrees" from Motion
- Click the green flag. The cat draws a perfect square!
You only used 2 blocks inside the loop, but the cat drew all 4 sides of a square. The loop did the repeating for you!
Try It: Draw a Triangle
Can you figure out how to draw a triangle? Here are some hints:
- A triangle has 3 sides (so repeat ___ times)
- The turn angle for a triangle is 120 degrees (not 90!)
Changing Colors
You can make your patterns more colorful by changing the pen color inside a loop. Each time the loop repeats, the color changes a little bit!
Step-by-Step: Colorful Square Spiral
- Start with "when green flag clicked"
- Add "erase all" from Pen
- Add "pen down" from Pen
- Add "set pen size to 3" from Pen (makes the line thicker and easier to see)
- Add "repeat 36" from Control
- Inside the repeat: "move 100 steps"
- Inside the repeat: "turn right 100 degrees" (not 90 -- try 100 for a cool effect!)
- Inside the repeat: "change pen color by 10" from Pen
- Click the green flag and watch the magic!
The sprite draws lines, turning slightly more than a right angle each time, and the color changes with each line. After 36 repeats, you get a beautiful star-like pattern in rainbow colors!
Try It: Experiment with Numbers
Change the numbers and see what happens:
- Change "move 100 steps" to "move 50 steps" -- what changes?
- Change "turn right 100 degrees" to "turn right 144 degrees" -- what shape do you get?
- Change "repeat 36" to "repeat 100" -- what happens?
- Change "change pen color by 10" to "change pen color by 1" -- how does the color change?
There are no wrong answers here! Experimenting is how real programmers discover new things.
Using the Stamp Tool
Another way to make visual patterns is the stamp block. Instead of drawing a line, "stamp" leaves a copy of the sprite wherever it is on the stage. You can use this to create rows, grids, or repeating designs.
Step-by-Step: Stamp a Row of Cats
- Start with "when green flag clicked"
- Add "erase all" from Pen
- Add "go to x: -200 y: 0" from Motion (moves the cat to the left side)
- Add "repeat 5" from Control
- Inside the repeat: "stamp" from Pen
- Inside the repeat: "move 80 steps" from Motion
- Click the green flag. You get a row of 5 cats across the stage!
Try It: Stamp with Size Changes
Make a growing pattern of cats! Add "change size by 20" (from Looks) inside the repeat block, after the stamp and move blocks. Each stamped cat will be bigger than the last one!
Bonus: Add "change color effect by 25" (from Looks) to make each cat a different color too. Now you have two things changing at once -- just like the double-change patterns from Lesson 2!
Geometric Art Challenge
Step-by-Step: Draw a Circle Pattern
Believe it or not, you can draw a circle using a repeat block!
- Start with "when green flag clicked"
- Add "erase all" and "pen down" from Pen
- Add "repeat 360" from Control
- Inside the repeat: "move 1 steps" from Motion
- Inside the repeat: "turn right 1 degrees" from Motion
- Click the green flag. The cat draws a circle!
How does this work? The cat takes a tiny step forward and turns a tiny bit, 360 times. After 360 tiny turns of 1 degree each, it has turned all the way around (360 degrees = full circle). It is the same idea as walking in a very large circle yourself -- lots of tiny steps with slight turns.
Try It: Create Your Own Geometric Art
Combine what you have learned to make something unique! Here are some ideas:
- Flower: Draw a circle, turn 36 degrees, draw another circle, repeat 10 times
- Spiral: Use a repeat block where the number of steps increases each time (use "change" blocks)
- Mandala: Draw a shape, turn a small amount, draw it again, with color changes
Try different numbers for steps, angles, and repeats. Some of the most beautiful patterns come from unexpected number combinations!
What You Just Did
Think about everything that came together in this lesson:
- You spotted the pattern in a square (move + turn, repeated 4 times)
- You used a loop (repeat block) to avoid writing the same blocks over and over
- You changed colors inside the loop to create variety
- You used stamp to create repeating visual patterns
- You experimented with different numbers to discover new shapes
These are real programming skills! Professional programmers use loops, pattern recognition, and experimentation every single day.
Check Your Understanding
1. What does the "repeat" block do in Scratch?
2. To draw a square, you use "repeat 4" with what two blocks inside?
3. What is the difference between "pen down" and "pen up"?
4. What does the "stamp" block do?
Key Takeaways
- The repeat block is a loop that runs blocks inside it a set number of times.
- Drawing a square uses "repeat 4" with "move" and "turn right 90 degrees" inside.
- The pen extension lets sprites draw lines. "Pen down" starts drawing, "pen up" stops.
- Changing the pen color inside a loop creates rainbow patterns.
- The stamp block leaves copies of the sprite on the stage.
- Experimenting with different numbers for steps, angles, and repeats creates amazing geometric art!
You Did It!
You have finished all four lessons in Module 2! You can now spot patterns everywhere and use loops in Scratch to create amazing art. Time to practice and take the quiz.
Practice Activities
Try 6 activities mixing pattern challenges with Scratch projects.
Practice Activities