Learn Scratch

Learn Scratch 3.0

What is Scratch?

Scratch is a block based programming environment developed by MIT Media Lab. It allows for the creation of games, animations, videos, stories, and so much more by simply connecting blocks of code together.

On the right is the user interface for Scratch. It is divided into three main sections.

1. On the left is the code library where all the different blocks of code are located. They are divided into separate categories which make finding the type of block you are looking for easier.

2. In the middle of the screen is where you "write your code" by dragging blocks from the library.

3. The right there is a window that allows you to see the effects of your code on the cat or whichever character you are writing code for.

Getting Started

Programming in scratch can be thought of as a combination of events and actions. One of the most common events that is used to trigger code to run is the "When green flag clicked" block.

Now when this event is triggered or activated by the user clicking on the green flag above section 3 (the results window on the right) whatever code will attach to it will run!

Adding an Action

Now that we have an event we can attach code underneath the event. Once the event happens, then the code under the event block will run.

In this example when the green flag is clicked the cat will move 10 steps.

Other Events

We can perform the same action with a different event.

In this example when the space key is pressed the cat will move 10 steps.

Try different numbers for steps and see how it affects the cats movement


Choose an event and some action and run your code to see what happens. You can change the motion, look, or sound of the cat.


The control section is another important part of programming with scratch. This section will allow you to loop code, wait between executing blocks of code, and write conditional statements. Let's take these one at a time!


While there are different types of loops, they all can be use to repeat the code that in place inside them. You can repeat single blocks of code or multiple depending on the task you are trying to accomplish.

In the example on the right when the green flag is clicked the cat will switch to its next costume forever unless then program is stopped.

This creates the appearance of the cat moving its legs in the same way a flip book creates the effect of movement when the pages are turned quickly.


Wait a minute! When I ran the code above the cat looked like a crazy person trying, what's wrong? The short answer is...nothing, the program is doing exactly what is written. The problem lies in fact that computers go do things very fast. So it is going to the next costume, but so quickly that it doesn't look they way we expect walking to look.

To fix this issue we can use a wait block. By inserting a wait block after the next costume block we are telling Scratch to wait 1 second before switching to the next costume.


While the above code solve the problem of crazy cat, it creates a new problem. Sloowwww cat! Waiting a full second is much too slow. See if you can fix the problem by adjusting the wait time until the walking motion looks natural.