Find a course

Module 1: What Is an Algorithm?Lesson 2 of 79 min

Sequences: Order Matters

Socks before shoes! Learn how a sequence works, why mixing up the order breaks a plan, and how to write exact steps a robot can follow.

Step 1 of 12Learn

One after another

A sequence is a set of steps that happen one after another, in a set order.

Order matters a lot. Try this plan for getting dressed:

  1. Put on shoes
  2. Put on socks

Silly, right? The steps are all there, but in the wrong order. Swap them and the plan works.

Computers follow a sequence from the top down, one step at a time. They never skip ahead and they never go back unless you tell them to.

Step 2 of 12Practice · Put in order

Put the steps for planting a seed in order.

Drag the items, or use the arrow buttons, to put them in order.

  1. Make a small hole with your finger
  2. Water the pot
  3. Drop the seed in the hole
  4. Fill a pot with soil
  5. Cover the seed with soil

Step 3 of 12Learn

The robot sandwich

Imagine a robot named Beep. Beep follows every instruction exactly.

You say: "Put peanut butter on the bread." Beep picks up the whole jar and puts it on top of the bread, lid still on!

You needed more exact steps:

  1. Open the jar.
  2. Pick up the knife.
  3. Scoop peanut butter with the knife.
  4. Spread it on one slice of bread.

Big jobs are made of many small, exact steps. Breaking a big job into small steps is called decomposition.

Step 4 of 12Practice · Choose one

Beep the robot is told "Put on your coat." What is the most likely problem?

Step 5 of 12Diagram

Exact steps for Beep: put on a coat

Exact steps for Beep: put on a coatProcess diagram: Pick up the coat → Hold it open → Left arm in → Right arm in → Zip it up.Pick up the coatHold it openLeft arm inRight arm inZip it up

Tap a shape with to see more.

Pick up the coat
Hold it open

Inside facing you.

Left arm in

Into the left sleeve.

Right arm in

Into the right sleeve.

Zip it up

From the bottom to the top.

Step 6 of 12Compare

Unclear steps vs. exact steps

AspectUnclearExact
Brushing teethBrush your teethPut a pea-sized blob of toothpaste on the brush, brush for 2 minutes, rinse
WalkingGo over thereWalk 5 steps forward, then turn left
BakingBake it for a whileBake at 350 degrees for 12 minutes

Step 7 of 12Practice · Spot the mistake

Tap the step that is in the wrong place in this plan for making toast.

Step 8 of 12Practice · Diagram

The toast plan, fixed

Tap the step that makes the bread start getting hot.

Tap the shape that answers the question, then press Check.

The toast plan, fixedProcess diagram: Take bread out → Bread in toaster → Push lever down → Wait for the pop → Eat the toast.Take bread outBread in toasterPush lever downWait for the popEat the toast
Take bread out
Bread in toaster
Push lever down

Now the toaster heats up.

Wait for the pop
Eat the toast

Last, because now it is ready!

Step 9 of 12Practice · Code challenge

This function gives the steps for washing your hands, but two steps are in the wrong order. Move the lines so the steps are: wet hands, add soap, scrub for 20 seconds, rinse, dry.

Runs in a sandbox in your browser.
  • washHands()

Step 10 of 12Note

Step 11 of 12Practice · Put in order

Put these steps for drawing a smiley face in a good order.

Drag the items, or use the arrow buttons, to put them in order.

  1. Draw a curved line for a smile under the eyes
  2. Color the face yellow
  3. Draw a big circle
  4. Draw two dots for eyes inside the circle

Step 12 of 12Practice · Fill in the blanks

Fill in the blanks

Steps that happen one after another in a set order are called a .

Word bank