Selection in Scratch

Learning Objectives

  • Use branching in a program to choose between different outcomes.
  • Start to create an interactive graphical story in Snap!
  • Source image for the the story
  • Look at and create a story map.

Learning Outcomes

All must create a simple program offering a choice of two location, and switch the background picture depending on the choice (Level 5)

Most should complete the above, using a principal character who changes position, and responds to different messages depending on the user’s choice. (Level 5)

Some could complete the above with no help, adding more locations/scripts to the story. (Level 6)


Words to learn: selection,  branching, if, then, else


Start off by opening Scratch 2.

Copy this code:

Now, run this by clicking the green flag.  Make sure you run it a couple of times, giving different answers.

This program is very limited.  In fact, it can make the computer look quite rude. In your exercise book write an answer to the following questions:

  1. How does the script work?
  2. Describe how it could be improved?

Main – Selecting an appropriate answer

Obviously, we need the program to respond in a different way to different answers.  Try this code:

Now, this is much better indeed.  If the answer is a specific word, we can can give a specific response.  In fact, we can use as many “if” blocks as we want to respond to different answers.

Of course, we still have a problem. What happens if the user types a different word? Absolutely nothing.  The program doesn’t respond at all.  It doesn’t work.  To get around this, we use an if/else statement.

Try this code:

This is better! We have a robust program, which responds to any answer.  Of course, now this program only works in two cases – the answer we expect, or one we don’t understand.  To improve this, we need nested if blocks.  This term just means an if statement inside an if statement.

Try this:


For each of the programs below, take a screenshot of the script and paste it into your exercise book with a suitable title and the date:

  1. Write a program which asks for a user’s age.  The program should say “You’re about to do your GCSE” if the answer is 14.
  2. Extend your program, so if the user’s age is below (<) 18, the program says “You’re too young to vote!”
  3. Extend the program further, so if the user’s age is greater than 17 it says “You’re old enough to drive”
  4. Extension: You need to make a program that chooses a random number (green menu!) between 1 and 10.  It says “Guess my number”  If the user guesses the number correctly, a message says “you’ve won!” otherwise it says “Better luck next time!

Main – Shipwrecked!

We’re going to start to build a story called “Shipwrecked”.

Visit openclipart to find yourself an interesting avatar (main character) and download the image.  If you are using Google Chrome it will automatically save to your H: drive in the Downloads folder.

Now, back on Scratch, right click the cat and choose Delete.  You then need to click the Upload Sprite from File button:

Browse to where the picture is saved and it will upload into Scratch.

Good.  Now find three pictures through Google images (and creative commons).  Your pictures must be of places you might find on a desert island.  I’ve included a first one here:


Go to the bottom left corner and click the “Upload backdrop from file” button:

Browse to where the picture is saved and it will upload into Scratch.  Do this for all three locations.

Now click on “scripts”.  Try this code:

Obviously the name of your images and locations will be different depending on what you have chosen.


  1. Expand this code so that you can choose between the three different locations.
  2. Open up this Scratch interactive story which is similar to the one you will be creating.
  3. Have a look at this story map – each box corresponds to a different location


This file is a template to start a “shipwrecked” story similar to the one you were playing above. Add as many boxes/links as you can to the map, with your ideas for places and dialogue.  Use your imagination as much as you can!