Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

5 Scratch Coding Exercises for Students in Grades 2–5

Five beginner Scratch projects teach events, loops, sensing, coordinates, costumes, sound, and variables, with step-by-step blocks, testing questions, and extensions.

Table of Contents

These five Scratch exercises introduce events, loops, sensing, movement, visual effects, sound, and size controls. They are designed for students in Grades 2–5, but the right pace depends on reading level and previous computer experience. Younger learners may need an adult to read block names and help with mouse control.

For each project, build the smallest working version, predict what the code will do, run it, and change one number. That cycle teaches more than copying a finished script without testing it.

Skills covered

ExerciseMain Scratch concepts
Flying cat follows the cursorGreen flag, forever loop, sensing, direction, movement
Jumping spriteKeyboard event, coordinates, reporters, costumes, glide
Color-changing backdropStage code, visual effects, loop timing
Sound on clickSprite event, sound playback
Resize with arrow keysKeyboard events, positive and negative values, limits

Exercise 1: Make a flying cat follow the mouse

A flying cat following the mouse in a Scratch project

Set up the scene

  1. Create a new Scratch project.
  2. Select the Stage, choose a backdrop such as Galaxy, and remove any backdrop you do not need.
  3. Choose a Flying Cat sprite from the sprite library.
  4. Place the cat away from the mouse pointer so you can see it begin moving.

Choosing a Galaxy backdrop in Scratch

Adding a Flying Cat sprite from the Scratch library

Build the script

On the Flying Cat, connect:

  • when green flag clicked
  • forever
    • point towards [mouse-pointer]
    • if <not <touching [mouse-pointer]?>> then
    • inside the if: move 5 steps

Scratch blocks that point a flying cat toward the mouse and move it

The cat points toward the cursor on every loop and moves only while it is not touching the cursor. Change 5 to 2 or 10 and describe how the motion changes.

Test and extend

  • What happens when the cursor moves behind the cat?
  • Add if on edge, bounce and compare the behavior.
  • Make the cat say “Caught you!” when it touches the pointer.
  • Add a Score variable that increases only once each time the cat reaches the pointer.

Exercise 2: Make a sprite jump

A Scratch sprite performing a simple jump

Choose a sprite with at least two costumes. This beginner version moves up and then returns to the starting height.

Build the script

  • when [space] key pressed
  • set [Start Y] to (y position)
  • next costume
  • glide 0.2 seconds to x: (x position) y: ((Start Y) + 50)
  • next costume
  • glide 0.2 seconds to x: (x position) y: (Start Y)

Create Start Y as a variable for this sprite only. Saving the starting value makes the return position explicit and prevents repeated jumps from slowly drifting.

Scratch blocks for a simple up-and-down jump

Test and extend

  • Change 50 to 25 and then 100. Which height fits the Stage?
  • Change 0.2 to 0.5. Does the jump feel slower or faster?
  • Play a sound at the start of the jump.
  • For a platform game, replace this simple glide with a velocity variable and gravity so the sprite can land on platforms.

Exercise 3: Create a color-changing backdrop

A Scratch backdrop cycling through color effects

  1. Select the Stage rather than the sprite.
  2. Choose a backdrop that changes visibly when a color effect is applied.
  3. Open the Stage's Code tab.

Selecting the Stage to program a backdrop

Blocks that change the backdrop color effect in a loop

Connect:

  • when green flag clicked
  • clear graphic effects
  • forever
    • change [color] effect by 5
    • wait 0.05 seconds

The reset block makes every run start the same way. The short wait makes the speed easier to control and prevents an unnecessarily tight loop.

Challenge

Create two keys: one that increases the color-change amount and one that decreases it. Decide on a minimum and maximum so the effect stays manageable.

Exercise 4: Play a sound when a sprite is clicked

Select the sprite, open Sounds, and choose a short effect from the library. Return to Code.

Choosing a sound for a Scratch sprite

Connect:

  • when this sprite clicked
  • play sound [chosen sound] until done

Scratch blocks that play a sound when the sprite is clicked

play sound until done waits before continuing; start sound allows later blocks to run immediately. Add a say block after the sound and compare the two sound blocks.

Challenge

Add a second costume and switch to it while the sound plays. Restore the original costume afterward.

Exercise 5: Resize a sprite with the arrow keys

Add two scripts:

  • when [up arrow] key pressedchange size by 10
  • when [down arrow] key pressedchange size by -10

Scratch scripts that increase or decrease sprite size with arrow keys

Now prevent extreme values. After increasing, if size > 200, set size to 200. After decreasing, if size < 20, set size to 20. On the green flag, set size to 100 so each run starts consistently.

Test and extend

  • Why is -10 used for shrinking?
  • What happens without the 20% minimum?
  • Display the current size in a speech bubble.
  • Replace the keys with clickable plus and minus sprites.

How to teach these exercises

  1. Predict: ask the student what each block will do.
  2. Build: add only two or three blocks at a time.
  3. Run: click the green flag or trigger the event.
  4. Explain: have the student describe the result in their own words.
  5. Change: modify one number, input, costume, or sound.
  6. Debug: compare the prediction with the actual behavior.

Students should be encouraged to rename sprites and variables, choose their own artwork, and add one original feature. The goal is not to reproduce the screenshot perfectly; it is to understand the relationship between an event and the blocks that follow it.

Common beginner problems

ProblemCheck
Nothing happensIs the script attached to the correct sprite or Stage, and was the right event triggered?
A block will not connectDoes its puzzle shape fit that position, and is it inside the intended loop or condition?
The wrong object movesSelect the intended sprite before adding code.
Several scripts keep runningClick the stop button, then restart with the green flag and reset values.
A sprite disappearsCheck size, x/y position, visibility, and whether it moved behind another sprite.

Reflection questions

  • Which block starts each script?
  • Which exercise uses a loop, and why?
  • What is the difference between x and y position?
  • What positive and negative numbers did you use?
  • Which feature did you invent, and how did you test it?
Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.