# 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.

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

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.

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 points the sprite in the specified direction. Scratch uses degrees in a circle to specify the angle to rotate the sprite to.

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

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

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.