Resources for Young Coders

Online Resources and Mobile Apps

You can learn more about Scratch by visiting the Scratch Forums or the Scratch Wiki.

EduBlocks lets you write code in your browser, including Python 3 and HTML5. You can use either a block-based format, like Scratch, or a text-based format, like a traditional text editor.

Grasshopper is a Code With Google program that teaches JavaScript and coding fundamentals. You can use it in your web browser or get the app on the Google Play Store.

Lightbot is a game where you use coding logic to solve puzzles. It’s available for Android, iOS and Amazon devices.

Books

There are lots of great books about learning Scratch that will take you from a newbie to an expert with lots of step-by-projects. DK Books has published many of them, including:

Coding Games in Scratch: A Step-by-Step Visual Guide to Building Your Own Computer Games

Coding Projects in Scratch: A Step-by-Step Visual Guide to Coding Your Own Animations, Games, Simulations

Coding with Scratch Workbook: An Introduction to Computer Programming

DK Books also has similar introductory books for the Python programming language. Python is a complete programming language used by professionals around the world. Its relatively simple syntax and wealth of modules make it a good language for beginners.

Coding Games in Python (Computer Coding for Kids) 

Coding Projects in Python (Computer Coding for Kids)

Advanced Scratch: Custom Blocks and Extensions (Make your own music!)

Custom Blocks in Scratch are an example of a function or method. They’re basically shortcuts: bits of code that you can use over and over again by calling the block, rather than reproducing it each time. This is very important as we get into more complex programs!

Music in Scratch

Music is an extra feature in Scratch. It’s hidden at first to give users a chance to learn the basics. To access Music (and other advanced features), look for the Add Extension button at the bottom left and select Music.

Some options, like selecting an instrument, are fairly straightforward. The “play note” command seems kind of tricky, but it’s really not! Drag it into your program and click in the space that says 60 and you’ll see a keyboard with Middle C selected. Any note can be selected by number or by key.

Each note is played for 0.25 beats, which corresponds to a quarter note in 4/4 time. If you don’t know the music theory, don’t worry — just know that 0.5 is twice as long as 0.25, 1 is twice as long as 0.5, etc. All of these notes together make up the first two lines of “Twinkle Twinkle Little Star” — now you know why we might want a shortcut!

We have our notes, now when do they play? Just like in gym class, they play when they’re called. If you look on the right, we see a command that says “When this sprite is clicked, Twinkle”. This tells Scratch when to run our custom block.

Advanced Scratch: Broadcasts

So far, most of our Scratch programs have had us follow a single sprite. This is great for making videos and animations, and we even made some basic interactive games using input, loops, and if/else statements. That’s a lot, really!

But think of your favorite games. There’s probably a lot of characters, and they interact in many ways: they have conversations, buy and sell items, or compete with one another.

In games, like in life, you need to communicate. Sprites in Scratch communicate with the Broadcast command.

Look at this demo. The program starts in a familiar way: when the green flag is clicked, the dragon says ROAR for 2 seconds. That’s great, but it doesn’t get much of a reaction… until we add the broadcast command. We’re calling our broadcast signal “roar” and seeing who picks it up.

If you click on the princess sprite, you’ll see that she has some code of her own. Her code starts when she receives a broadcast called roar, and has her saying “A DRAGON!” for 2 seconds.

Intro to Scratch Programming: Loops

When green flag is clicked, forever create clone of myself, go to random position

Forever loops  are a form of infinite loop. Some of you might already be thinking, “Oh no! That’s a bug!”

Usually we don’t want loops to go on forever. Think back to the story of the sorcerer’s apprentice. He had a job that was boring and repetitive, and he thought: I can automate this! He cast a spell on a broomstick and told it to carry water from the well. But he didn’t know the spell to make it stop!

Infinite loops are like that spell, they go on forever. Lucky for us, Scratch is much better than the apprentice at keeping loops contained. If you want to make an animation that loops continuously, the forever loop is what you want.

When the green flag is clicked, repeat 13 times: say Na for 0.25 seconds and wait 0.1 seconds. Then say BATMAN

Another type of loop is repeat. You may have seen this type of loop called a for loop. This loop starts off by saying how many times it should repeat.

Our repeat loop, which helps us remember the theme to the 1966 tv series Batman, repeats 13 times. Each time through the loop, our sprite says “Na” and waits. After we’ve gone through 13 times, we can finally progress past the loop and say BATMAN.

Why do we wait 0.1 seconds? Without this wait, we wouldn’t see 13 distinct “Na” lines, just one “Na” for 3.25 seconds (0.25 * 13).

You can see this code in action on Scratch.

When the green flag is clicked, repeat until touching Bananas: glide 1 secs to random position. Then say "Bananas!" for 2 seconds. Then go to x -162 y -97

Another type of loop is the repeat until loop. This loop will run until a condition is met. This code tells the monkey to glide around the screen at random until it reaches the bananas.

Unlike the repeat loop in our last example, we don’t know how many times the loop will repeat — our monkey is just too unpredictable! But with the repeat until loop, we don’t have to.

Before entering the loop, we check if we’re touching the bananas. If we are, we can skip the loop. If not, we enter the loop and glide for 1 second to a random position, then go back up to the top and check again.

After the loop is finished, our monkey says “Bananas!” for two seconds and then returns to his starting position.

You can see our monkey in action on Scratch.

Intro to Scratch Programming: If/Else and Variables

Variables can be used to store data. Two main types of variables are numbers and strings. Strings are words or phrases.

This program has a variable called answer that’s created when we use the ask block. The value of answer is whatever name the user enters in response to the question “What’s your name?”

We can use our variable to greet the user by name! Our say block includes a join — this concatenates, or glues together, the phrase “Hello, ” with the value of our answer variable. So if you entered the name “Jane” it would say “Hello, Jane”

See our Scratch variables in action!

The If/Else block can be used to choose between two options based on input.

Just like in our greeting program, we have an ask block that stores its response in the variable called answer.

The value of answer is used to make a choice. If the value is equal to “city”, Scratch changes the backdrop to Colorful City.

The else block contains a nested if statement testing if the value of answer is farm. If it is, Scratch changes the backdrop to Farm.

We need this additional check because the text box allows the user to enter any word and we don’t want everything that isn’t “city” to send them to the farm!

See our If/Else statements in action on Scratch!

Here’s is a more complex program that uses variables, loops, and nested if statements.

The first block has Scratch set the value of the variable my variable  to a random number between 1 and 10.

Next there is a repeat until loop that runs until the value of answer is equal to my variable — that is, until the user has the correct guess.

If answer is equal to my variable, nothing in the loop runs. Scratch runs the next block, which says “You got it!”

This may seem strange as a first step, even before the ask block. In practice, our loop will have to run at least once to have a value for answer that can match my variable. The repeat until condition says when the loop can stop running: when we have the answer.

The first step in every loop is to ask for a number and store that number in answer. We check if answer is too high or too low, to give the user a hint. Then we loop back up to the top to see if maybe the answer is just right.

Sounds like fun? Maybe you’d like to play our number guessing game on the Scratch website.

Introduction to Scratch Programming

Scratch is a programming language based on dragging and dropping different blocks. This means you can explore and start programming without the hassle of fixing typos and syntax errors.

Scratch programming is all done in the web browser, at scratch.mit.edu. The Scratch website includes its own tools for creating and modifying graphics, sounds and music — everything you need to create a fun and unique program.

A couple important elements in Scratch that you’ll see in almost every program. The first is your sprite, you’ll see when you first open up Scratch there’s a little Scratch cat on the top right. This is the default sprite for Scratch, you can add more from their library, from uploads, or from the paint program that’s right inside Scratch! All of the code in the center part of you screen is tied to this sprite. You can also add more sprites with their own code.

You’ll also notice a green flag and a stop sign. The stop sign is pretty straightforward; it stops whatever code is running. The green flag, however, only has an effect if you use the event “when green flag is clicked”. You’ll find this event in most Scratch programs.

For our most basic program, the “Hello World” program, we’ll use the green flag event and drag that into the center of the screen. Then we’ll need to go to the Looks category and find one that says “say Hello! for 2 seconds”. Notice that this block has a particular shape that we can attach it to our green flag event. Then we can change the default “Hello!” message to say “Hello World!”

Try it out! Click the green flag and see the Scratch cat offer you a greeting, then check our more lessons.