Skip main navigation

Sequencing

Computers will follow the instructions you've given them, step by step. Read why getting your instructions in the right order is important here.

In the previous steps you have created instructions to control a sprite in Scratch. The order of instructions is important when creating programs. This is known as sequencing.

The importance of sequencing

There are often ambiguities in human communication, so we have to infer meaning to correctly interpret instructions. Computers can’t do this: they just run the code in the program in order, unless instructed otherwise.

Imagine that you were instructing a friend to record a short video and post it on their social media account using a smart phone.

You might start by instructing your friend to unlock the phone. It’s important that this happens before you try to get them to do anything with the camera on the phone. Unlike your friend, the computer would not be able to realise that the “unlock the phone” instruction should be run first if you miss it out. When programming, you have to make sure that you give all of the instructions in the correct order, as the computer will go through them in that order, and won’t do anything it wasn’t explicitly told to do.

When you may give your friend an instruction, you may wait until they have completed the instruction before moving on to the next step. Similarly, when programming a computer you give a set of instructions, but unlike when instructing your friend, you wouldn’t be able to see how the computer has responded to each instruction before you give it the next one. Instead, you would write the entire set of instructions, or program, and then run them. When you instruct the computer to run the instructions, it will follow the instructions that it understands in the given order. This means that it’s important to get the order correct.

The following Scratch code will move the sprite around in a square.

A sequence of Scratch code: when flag clicked, move (150) steps, wait (5) seconds, turn right (90) degrees, move (150) steps, wait (5) seconds, turn right (90) degrees, move (150) steps, wait (5) seconds, turn right (90) degrees, move (150) steps, wait (5) seconds, turn right (90) degrees.

Screen recording of Scratch showing the Cat sprite moving in a square when the above code runs.

The next set of code contains all of the exact same blocks, but the sprite will only move along a straight line.

A sequence of Scratch code: when flag clicked, move (150) steps, wait (5) seconds, turn right (90) degrees, turn right (90) degrees, wait (5) seconds, move (150) steps, move (150) steps, wait (5) seconds, turn right (90) degrees, turn right (90) degrees, wait (5) seconds, move (150) steps.

Animation showing the cat sprite moving forwards, turning around 180 degrees, moving back to its starting position, moving further in that direction, turning around 180 degrees again, and moving back to its original position.

Even though the second program doesn’t work as intended, Scratch will still run these instructions in this sequence — it’s up to you to make sure that you give the instructions correctly.

Understandable instructions

In order for your friend to follow your instructions, the instructions need to be in a format that your friend will understand. For example, your friend may not understand words read straight from a manual, such as ‘facial recognition’ or ‘passcode’, and these words need explaining. Whereas your friend may be able to infer what you mean, look at a diagram, or ask questions to help them understand your instructions, this is not possible for a computer. Computers only understand certain instructions or commands, given in the programming language that the user is programming with.

Achieving your aim

After your friend has finished following your instructions to record a short video and post it on their social media account, they will be able to look at the video on the social media platform and evaluate if they have been successful. Computers do not have the capacity to evaluate whether they have carried out a program of instructions as the programmer wanted. They will follow the instructions regardless of whether they are successful in producing the output expected by the programmer or not.

Different sequences

Even though changing the sequence can change the outcome of the program, there is often more than one way to sequence instructions to achieve the same outcome.

If I want to move the sprite to the top right corner of the Stage, I can use blocks you have used in previous steps and the point in direction () block.

The `point in direction ()` block.

The point in direction () block points the sprite in the specified direction. Scratch uses degrees in a circle to specify the angle to rotate the sprite to.

The Cat sprite facing to the right. It is surrounded by a circle with numbers marked every one eighth of the circle around it, starting from 0 at the top. Clockwise from this, the numbers are 45, 90, 135, and then 180 at the bottom. Anticlockwise from 0, the numbers are -45, -90, -135.

This sequence moves the sprite to the top right corner of the Stage:

Scratch code: flag clicked, go to x:(0) y:(0), point in direction (90), move (150) steps, point in direction (0), move (150) steps.

You can also move the sprite to the top right corner of the Stage with this sequence of instructions:

Scratch code: when flag clicked, go to x:(0) y:(0), point in direction (0), move (150) steps, point in direction (90), move (150) steps.

Both programs have the same outcome and instructions but the instructions are in different orders.

Next step

As you work through the rest of this week, keep in mind the idea of sequence, and think about what effect (if any) changing the order of the blocks in each program would have.

In the next step, I’ll show you some more blocks that you can use for moving your sprites.

This article is from the free online

Introduction to Programming with Scratch

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education