First Programs, Sequences and Debugging

Learn to give a floor robot or a character on a screen commands in the right order. You will build short programs, predict what they will do before you run them, and find and fix bugs when something goes wrong. At the end you plan, build and test a program of your own.

Kindergarten, Grade 1Lesson 1 of 10 in Computing and Coding for Ages 7 to 11 Course

What you will learn

  1. Find out what commands, programs and code are, and build short programs that make a floor robot or a character on a screen do what you want.
    • Learn what commands, programs and code are
      Learn the words programmers use, see why a robot follows code exactly, and find out when the order of commands changes what happens.
    • Program a floor robot to reach a target
      Use forward, backward and turn commands to send a floor robot across a mat of squares, and write your program down with arrows.
    • Build a program with blocks for a sprite
      Snap command blocks together to make a character on a screen move, talk and play sounds, starting the same way every time.
  2. Read a program before you run it, work out what will happen step by step, and explain your thinking.
    • Follow a program one step at a time
      Trace a program with your finger or a counter, keep track of where the robot is and which way it faces, then run it to check your prediction.
    • Explain your prediction and what a change will do
      Use what you know about each command to give reasons, compare programs, and work out what happens when you change the code.
  3. Spot what kind of mistake is in a program, track down exactly where it is, fix it and test again until the program works.
    • Spot the kinds of bugs in a program
      Learn what a bug is and recognize the mistakes that often happen in a sequence: wrong order, a missing step, an extra step, the wrong command and the wrong number.
    • Find where the bug is
      Use debugging strategies to track down the exact command that is wrong: compare what you wanted with what happened, step through the code, and talk it through with a partner.
    • Fix the bug and test again
      Make one small change to fix the bug, run the whole program again from the start, and keep going until it works.
  4. Choose a goal, plan the steps, turn your plan into code and test it as you go, so your own program works and is easy to follow.
    • Turn a plan into code
      Decide what your program should do, plan the steps as an algorithm, and change each step into commands the robot or sprite understands.
    • Test as you build and make your program better
      Test your program often while you build it, check it against your goal, tidy it up and learn from the bugs you find.

Sequences and Debugging study guide

4 chapters

1

Give your robot a job

You can make a robot travel or a screen character talk. First, you choose commands and put them in order. You will try command cards, buttons, and blocks, and see how each one works. The robot’s front and the sprite’s screen give you different ways to think about a move.

1.1 Commands make things happen

You can tell a robot what to do with a command. One command gives one instruction, such as "move forward". A list of commands for a robot or computer is a program.

Make a plan, then write code

An algorithm is a plan made of steps for a job. Think about brushing your teeth. You put toothpaste on the brush before you brush. Each step has a place in the plan.

A program is a plan written in commands a computer understands. Those commands are called code. Writing them is coding, or programming. Your robot may understand "forward" but have no command called "visit the door". You must break that job into commands it knows.

Put the commands in order

The order of commands is a sequence. In these programs, the robot follows one command, then the next. It starts with the first and works toward the last.

Imagine a robot facing away from you. Compare these programs:

ProgramWhat happens
forward, turn rightIt moves one square ahead, then faces right.
turn right, forwardIt faces right, then moves one square to that side.

The commands are the same, but their order changes the stop square. The robot cannot guess that you meant the other route.

Sometimes a swap keeps the same result. On a number track, start at 0. Move forward 3, then forward 2: you stop at 5. Start at 0 again. Move forward 2, then forward 3: you also stop at 5. Trace the moves to check a swap.

Play the robot game

Lay command cards in a row. One person reads the cards. Another acts as the robot, following each card exactly. Use "step forward", "turn left", and "turn right" on a clear path. If the route misses the target, look at the cards. The person acting as the robot should not guess a better route.

People write programs for tablet games, washing machines, microwaves, and traffic lights. The commands make different things happen, but their order still matters.

Key Takeaways

  • A command tells a robot or computer to do one thing.
  • An algorithm is a step-by-step plan; a program writes the plan as code.
  • A sequence is the order of commands.
  • Trace a change in order to check what it does.

1.2 Send a floor robot across a mat

A floor robot follows commands you enter with its buttons. On a mat made for that robot, one move takes it one square. First choose a start square and the way its front will face.

Know what each button does
CommandWhat the robot does
forwardMoves one square the way its front points.
backwardMoves one square behind it without turning.
turn leftMakes a quarter turn left on the same square.
turn rightMakes a quarter turn right on the same square.

To reach the square on its right, use turn right, forward.

Left and right belong to the robot. If it faces you, its right is on your left. Stand behind it, or face the same way with your own body. Now your right matches the robot’s right.

Count the moves to the cheese

The cheese is 2 squares ahead, then 1 square right. Trace that path with a finger. Count each new square you enter. Do not count the start square as a move.

  1. forward: move onto the first square ahead.
  2. forward: move onto the second square ahead.
  3. turn right: stay on that square and face right.
  4. forward: move onto the cheese.

The full program is forward, forward, turn right, forward.

Write arrows before pressing buttons

You can use arrows to record the commands:

  • ↑ means forward.
  • ↓ means backward.
  • ↰ means turn left.
  • ↱ means turn right.

The cheese program is ↑ ↑ ↱ ↑. The forward arrow means "follow the robot’s front". After a turn, it does not mean "go toward the top of the paper".

Get ready to run

On many floor robots, button presses stay in memory. New presses join the old commands. Press Clear before entering a new program on these robots. Then press the command buttons in the order you wrote.

Put the robot on Start, facing the planned way. Press Go to run the whole program. If the robot misses the target, check its start square and facing as well as the commands.

Key Takeaways

  • Forward follows the robot’s front; backward moves behind it without turning.
  • A left or right turn is a quarter turn on the spot.
  • Use the robot’s left and right.
  • Count new squares, leaving out the start square.
  • Clear stored commands before entering a fresh program, then use Go to run it.

1.3 Make a sprite move, speak, and play sounds

A sprite is a character or object you can control on a screen. It could be a cat, a car, or a ball. Select the sprite you want to program, then drag blocks into its code area.

Snap the blocks together

Connected blocks make a sequence. Some apps read left to right. Others read top to bottom. Follow the direction your app uses. A loose block does not run with the connected program.

Put a start block such as "when green flag clicked" first. Pressing the green flag starts the attached blocks. Each sprite has its own code, so check that you selected the right character.

Choose what happens

Motion blocks move or turn your sprite. Many have a number you can change. In an app that counts grid squares, "move right 3" moves three squares. It reaches the same place as three "move right 1" blocks.

Read the command words carefully. A screen command called "move right" can move toward the screen’s right side, whichever way the sprite faces. A floor robot’s forward command follows its front.

Looks blocks can show words, change size, hide, or show the sprite. Sound blocks play sounds. They belong in the sequence too.

Help the cat reach a ball

The ball is 4 grid squares to the cat’s right. You want the cat to reach it before speaking.

  1. Start with "when green flag clicked".
  2. Snap on "move right 4".
  3. Snap on "say Got it!".

Press the flag. The cat moves first, then says "Got it!". Swapping the last two blocks makes it speak before moving.

Play notes in order

Sound order changes a tune. "Do, re, mi, do" begins "Are You Sleeping, Brother John?". "Mi, re, do, do" has a different order. In apps with both sound choices, "play sound until done" waits for a sound to finish. "Start sound" lets the next block begin straight away, so sounds can overlap.

Give each test the same start

Place a "go home" or position block just after the start block. It puts the sprite back in its start place. A position reset sets only its place. If your program changes its facing, size, or whether it shows, add blocks to set those back too. A hidden sprite needs "show"; moving it home alone will not make it visible.

Key Takeaways

  • A sprite is a screen character or object controlled by code.
  • Snap blocks together and place a start block first.
  • Each sprite has its own code.
  • Read movement words and numbers before planning a path.
  • Looks and sound blocks run in the sequence too.
  • Reset every starting feature that your program changes.
2

Work out the route before running

You can work out a program’s journey before it starts. Use a counter or your finger to follow each command. Keep track of turns as well as moves. Then you can explain your answer and compare two routes, even when they reach the same place.

2.1 Trace each command

Before you run a program, predict what it will do. A prediction says what you think will happen. You can work it out by tracing: follow the code one command at a time.

Give your counter a front

Put a counter on the start square. Draw a small arrow on it to show its front. Point to the first command and act it out. Then point to the next command.

Keep track of two things: the square and the facing. A forward or backward changes the square. A turn changes the facing. Keep the counter on the same square while it turns.

Follow a route with two turns

Start facing toward the top of the mat. Trace this program:

forward, forward, turn left, forward, turn left, forward

  1. The first forward takes you one square ahead of Start.
  2. The next forward takes you two squares ahead of Start.
  3. Turn left on that square. Your front now points left.
  4. Move one square left.
  5. Turn left again. Your front now points toward the bottom.
  6. Move one square toward the bottom.

You finish one square ahead of Start and one square left. You face the bottom of the mat. Count the moves after each turn in the new facing direction.

Leave a trail on paper

For a longer program, write a short note after each command. For the first three steps above, your notes could be "1 ahead", "2 ahead", and "2 ahead, facing left". The last note tells you the final square and facing.

A turn takes a step in your list, but no step across the mat. If you move onto a new square during a turn, your trace will put every later move in the wrong place.

Trace a sprite too

Read "when green flag clicked", "move right 2", "move up 1", "say Hi!". The flag starts the code. The sprite moves two grid squares right, then one up. Only then does it say "Hi!".

Now run the program and watch each action. If the result differs from your prediction, read the commands again. You may have traced a move wrongly, or the code may need a fix. Find the step where your trace and the run first part ways.

Key Takeaways

  • Predict before running, then check by watching the run.
  • Trace every command in order.
  • Track both the square and the facing.
  • Keep your counter still during a turn.

2.2 Give reasons and compare changes

A prediction is stronger when you can say why. Logical reasoning means using what you know about each command to work out what happens. You might say, "It reaches the flower because three forward moves cover the three squares."

Compare two routes

Start with a robot facing ahead. A star is one square ahead and two squares right. Trace each program from the same start.

  • Program A: forward, turn right, forward, forward.
  • Program B: turn right, forward, forward, forward.

Program A moves one ahead, then two right. It reaches the star. Program B turns before moving. It travels three squares right along the start row, so it misses.

There is another route to the star: turn right, forward, forward, turn left, forward. It goes right first, then ahead. Both that route and Program A reach the target. The paths differ, and their final facing differs too.

Think about one change

If "forward 3" becomes "forward 2", that move ends one square sooner. The next command begins from the new place. Trace the rest to see where the whole program ends.

Changing a left turn to a right turn changes the facing at that point. Later forward moves follow that new direction. Do not change only the turn in your drawing and leave the later path untouched.

Spot commands that undo each other

A right turn followed by a left turn puts the front back where it was. Both turns happen on the same square. So forward, turn right, turn left, forward ends where forward, forward does, with the same facing.

Use a miss as a clue

A robot stops short of a flower. First check its start square and facing. Then trace the code. On a straight path from the right start, a missing forward move may explain the miss. A wrong turn or number can also cause a miss. Look at the actual steps before choosing a fix.

If a prediction was wrong, ask, "Which step surprised me?" Act out that command. Its meaning helps you explain what happened.

Key Takeaways

  • Explain a prediction using what each command does.
  • Trace each program from the same start when comparing routes.
  • Different paths can reach the same target.
  • After changing a command, trace the later commands too.
  • Check the start and trace before deciding why a target was missed.
3

Find the bug and try a fix

A robot can finish its program and still miss its target. Watch what happens and compare it with your plan. You will learn to spot the first wrong step, make a small fix, and try again. Each test gives you a clue about what needs to change.

3.1 Recognize a bug

A bug is a mistake in code that stops the program doing what you wanted. Debugging means finding and fixing bugs. Even expert programmers need to do it.

Look at the kind of mistake
BugWhat to look for
Wrong orderNeeded commands are there, but in the wrong places.
Missing commandA needed step is not there.
Extra commandThe list has a step you do not need.
Wrong commandOne command should be a different command.
Wrong numberA block’s number is too large or too small.

These clues help you choose what to inspect. Check them against your goal and your route.

Compare code with the job

The cheese is two squares ahead and one right. The robot starts facing ahead. The program is forward, turn right, forward, forward. It goes only one ahead before turning, then two right. All four needed commands are there. The order is wrong. Use forward, forward, turn right, forward.

A flower three squares straight ahead needs three forward moves. A list with two forwards has a missing command. A list with four forwards has an extra command and goes past the flower.

A left turn in place of a needed right turn is a wrong command. A sprite’s "move right 5" goes past a ball four squares right. Its number should be 4.

Listen for a sound bug

In some apps, "start sound" begins a sound and moves straight on. Two of these blocks can start sounds that overlap. If you want one sound to finish before the next begins, use "play sound until done" blocks. The wrong sound-block type can make your tune run together.

Check more than the code

The robot may begin on the wrong square or face the wrong way. On a robot that keeps commands, an old list may remain because Clear was missed. Check these before changing a correct route.

A program can have a bug even when it runs to the end. Watch what it does and compare that with your goal. Finishing a list is not the same as reaching the target or playing the sounds in order.

Key Takeaways

  • A bug stops the program doing what you wanted.
  • Look for wrong order, missing or extra commands, a wrong command, or a wrong number.
  • Check sound blocks when sounds overlap.
  • Check the start and stored commands before changing code.
  • Compare the result with the goal, even when the code finishes.

3.2 Find the first wrong step

Finding a bug is easier when you know what you expected. Say the goal and the result: "I wanted the robot on the ball. It stopped on the other side."

Watch where the route first changes

Start facing ahead. The ball is one square ahead and two left. Your code says forward, turn right, forward, forward.

The first forward matches your plan. At the second command, the robot faces right. Your plan needs it facing left. This is the first wrong step, even though it has not left the square yet. The right turn is the bug.

Later moves may follow their commands correctly but still start from the wrong facing. Work from the first difference so you do not try to repair every later square separately.

Step through slowly

Point to one command at a time. Act it out with a counter, then compare it with the drawn route. Keep the arrow cards next to the mat so you can check both together.

Stop when a command differs from the plan. A needed command might also be missing just before that point. If your plan needs a turn but the next command is forward, check for the missing turn.

Make a fast program easier to watch

A sprite can move so quickly that you only see its last place. Put a "wait" block between actions to slow the run. Now you can notice whether it spoke too early or moved too far.

You can also test just the first few commands. Start from the planned start and run that part. If it reaches the right square and facing, look later in the code. When you test a longer part, begin from the same start again.

Talk through the blocks

Tell a partner what each block does. You can even tell a toy: "First it moves ahead. Next it turns right." Speaking the turn’s name may help you hear that it should be left. A partner can check the route while you point to the code.

If nothing starts, check the starting things. Is a start block attached? Are the blocks on the right sprite? For a floor robot, check Start, facing, and cleared memory before looking for a wrong move.

Key Takeaways

  • Say what should happen and what actually happened.
  • Step through until the first difference from the plan.
  • A turn can be the first wrong step without changing squares.
  • Use short tests or wait blocks to see the actions.
  • Explain the code aloud to help find a bug.

3.3 Make a small fix and run again

Once you find the bug, change the part that is wrong. Keep the parts that already do their jobs. You might swap commands, add one, remove one, or change a command or number.

Fix the turn

The ball is one square ahead and two left. The robot starts facing ahead. You found the wrong turn in forward, turn right, forward, forward.

Change just turn right to turn left. Your new program is forward, turn left, forward, forward. The first move still takes the robot one square ahead. The new turn faces it left. The last two moves take it to the ball.

Changing the first forward would not fix that wrong turn. Match your change to the clue you found.

Test one change at a time

Make one change, then test. If you change the turn and remove a forward together, the result changes in two ways. You will not know which change helped.

Use the same starting things for the test:

  1. Put the robot back on Start.
  2. Face it the planned way.
  3. Clear stored commands and enter the fixed program.
  4. Press Go and watch the whole route.

For a sprite, reset the starting place and any changed facing, size, or showing. Then press the green flag.

Check the whole job

A fix might let the robot get farther and reveal another bug. It could make the right turn but still stop short. Check all the steps, including the last move, words, and sounds. Keep finding and fixing bugs until the whole program meets your goal.

If your change did not help, change it back and trace again. Look for the first difference between the plan and the run. You do not need to start a completely new program each time.

You can say, "I haven’t fixed it yet." A test tells you what to look at next. When you spot the next bug, make another small change and try again.

Key Takeaways

  • Change the part that is wrong and keep the working parts.
  • Fix one thing, then test.
  • Restart from the planned place and facing.
  • Run the whole program to check for more bugs.
4

Make your own working program

Choose a small job for your robot or sprite. You might send a car to a garage or make a character greet a friend. Draw or tell the steps before you build. Then test a little at a time, and make your code easy for someone else to follow.

4.1 Turn your idea into commands

Choose what you want your program to do. Say the goal in plain words, such as "The car drives to the garage and beeps." Decide where it starts and where it should finish.

Draw or tell the plan

Trace a route with your finger, or draw it on a grid. For a story, sketch the actions like pictures in a comic strip. Say what happens first, next, and last.

This plan is your algorithm. You can change it before spending time snapping blocks or pressing buttons.

Break a big step into small commands

A floor robot does not have a button called "visit the garage". Look at the route and use commands it knows.

The garage is two squares ahead and one left. The robot begins facing ahead. Your plan says, "Go two squares, turn toward the garage, then go one square."

Build the code step by step:

  1. Two squares ahead needs forward, forward.
  2. Facing the garage needs turn left.
  3. The last square needs forward.

Write ↑ ↑ ↰ ↑, then trace it to check. The turn is on the second square ahead, before the last move.

Plan a sprite’s story

A cat walks in, says "Hello!", then jumps. In a grid app, you could use "move right 3", "say Hello!", then "hop" after the start and reset blocks. The speech belongs between walking and hopping because that is the story you planned.

Select the character before giving it blocks. Each sprite has its own code. Get one character working before building another character’s part.

Check both the plan and the code

Lay the code next to the drawn path or story pictures. Does each planned step have commands? Are they in the right places?

If the code follows the plan but still misses the goal, check the plan too. You may have counted the route wrongly. If the plan is right and a block differs, fix the block.

More than one program can reach a goal. A shorter one is often easier to read, but it must still do every part of the job. Check the route and the finish before choosing it.

Key Takeaways

  • Say the goal and choose the start before building.
  • Draw a path or story plan in order.
  • Break each big step into commands the robot or sprite knows.
  • If the result is wrong, check the plan as well as the code.

4.2 Build a little, test a little

Testing means running your program to check that it does what you wanted. You can test before the whole program is finished. A bug is easier to find in a few new blocks than in a long untested list.

Add one small part

Build the first few commands. Predict what they do, run them, and check the result. Fix any bug before adding the next part.

For a car that should reach a garage and beep, first get the journey working. Check the stop square. Then add the beep and check that it happens after the journey. Each new part has a clear job you can test.

Let the goal guide your test

Look for every part of the goal. A robot might reach the right square but face the wrong way. A sprite might reach its place but say the wrong words. Watch and listen to the whole run.

Ask a friend to test too. Tell them the goal and let them say what they saw. Kind feedback names something that works and something to fix: "The car reaches the garage. The beep needs to come after the move."

Make code easier to read

Look for commands that undo each other. A right turn followed straight away by a left turn leaves the robot on the same square, facing the same way. If your goal only needs that route and finish, you can remove both turns.

In a grid app that allows numbers in move blocks, four "move right 1" blocks can become one "move right 4" block. The sprite reaches the same place. Check that your goal does not need separate actions between those moves.

Test again from the start after tidying. A shorter list is useful only if it still does the job.

Share what you learned

Show a partner each part of your code and say what it does. Tell them about one bug you fixed. You might say, "I counted Start as a move. Now I count only the squares the robot enters."

Use that lesson on your next program. If left and right were tricky, check from behind the robot before entering its turns. If a block was loose, check the joins as you build.

Key Takeaways

  • Test a few commands before adding the next part.
  • Check every part of the goal, including words, sounds, and facing.
  • Use kind, clear feedback when testing with a friend.
  • Remove unneeded commands or combine matching moves where the app allows it.
  • After tidying, test from the start.
  • Remember a bug you fixed and check for it next time.

Sequences and Debugging examples

4 Walkthroughs

1

Give a robot and a sprite a job

18 steps
Build commands into a route, then make a screen character act in order.
  1. 1
    IntroductionFrom an idea to a program

    You want a robot to reach a toy tree. "Visit the tree" names the job, but the robot needs smaller steps. You will choose commands, put them in order, and check turns. Then you will build a short block program for a sprite on a screen.

  2. 2
    ExplanationOne command, then another

    A command gives one instruction, such as "forward". A program lists commands for a robot or computer to follow. The commands are called code. In your sequence, each command has a place: the first runs before the second, and so on.

  3. 3
    AnalogyPlan the job first

    Think about steps for getting ready to draw: get paper, choose a crayon, draw. A step-by-step plan is an algorithm. A program writes a plan in commands a computer knows. For the robot’s trip, you need move and turn commands instead of drawing steps.

  4. 4
    ExampleTry a swap

    Put a counter on Start, facing the top. Act out forward, turn left. It moves ahead, then faces left. Put it back and try turn left, forward. It now moves left from Start. The same commands reach different squares because the order changed.

  5. 5
    ChallengeWill these end together?

    On a number track, start at 0. One program moves forward 1, then forward 4. Another moves forward 4, then forward 1. Do they end together?

    ---reveal---

    Yes, both stop on 5. Both move five places forward. This swap keeps the total distance on the same straight track.

  6. 6
    ExplanationTurn without traveling

    On your robot’s mat, forward moves one square toward its front. Backward moves behind it without turning. A left or right turn is a quarter turn on the spot. Act out a right turn: your front changes direction, but your feet stay in place.

  7. 7
    TipStand behind your robot

    Use the robot’s left and right. When it faces you, its right lies on your left. Stand behind it, facing the same way. Point your right hand toward its right. This helps you choose the turn before entering the route.

  8. 8
    ExampleFirst, reach the turning square

    The tree is three squares ahead and one left of Start. Your robot begins facing the top. Lay down ↑ ↑ ↑. Each arrow means forward. Count the three new squares it enters. It is now beside the tree’s row, still facing the top.

  9. 9
    ExampleNow, turn toward the tree

    Keep the robot at that turning square. Add ↰ ↑: turn left, then forward. The turn changes its facing without moving it. The forward enters the tree square. Your complete route is ↑ ↑ ↑ ↰ ↑. On a robot that stores commands, Clear first, enter the list, and press Go.

  10. 10
    ChallengeReach a toy beside Start

    A robot faces the top. A toy is one square to its right. Sam enters only ↱. Where does the robot stop, and what command is missing?

    ---reveal---

    It stays on Start, now facing right. Add ↑ after the turn to reach the toy. Here the forward arrow follows the robot’s new front.

  11. 11
    ExplanationChoose the sprite

    A sprite is a character or object on a screen. Select the sprite before dragging blocks into its code area. Its blocks control that sprite. Snap the blocks together, following your app’s order, either across the screen or down the page.

  12. 12
    ExampleStart, reset, then move

    A bird should move to a nest five grid squares right of Home. Start with "when green flag clicked". Snap on a position reset to Home, then "move right 5". In this grid app, the move counts squares toward the screen’s right side.

  13. 13
    ExampleSpeak after arriving

    Add "say Home!" after the move. The connected program starts, resets the bird, moves right five squares, and then shows "Home!". A speech block changes what you see. A sound block can add something you hear, such as a chirp after the speech.

  14. 14
    Key InsightReset more than place when needed

    Suppose the bird grows and hides at the end of its run. Moving it home next time changes only its place. Add blocks after the start that restore its starting size and make it show. Otherwise the next test begins with a large, hidden bird.

  15. 15
    ChallengeWhy is the speech missing?

    Your bird moves to the nest, but its "say Home!" block is loose beside the program. How can you make it speak after arriving?

    ---reveal---

    Snap the speech block onto the end of the bird’s connected sequence. A loose block does not run with that sequence, even when it sits near the move.

  16. 16
    TipLet each sound finish

    Some apps have both "start sound" and "play sound until done" blocks. The first begins a sound and carries on. The second waits for it to finish. For a tune whose sounds must play one after another, choose the waiting blocks so the sounds do not overlap.

  17. 17
    ChallengeCheck a fresh robot run

    You wrote a new route to the tree. Your robot keeps old commands, and its front now faces left. Your plan starts facing the top. What must you set up before entering and running the new route?

    ---reveal---

    Clear old commands. Put the robot on Start facing the top, then enter the new route and press Go. The code and the starting setup both affect the trip.

  18. 18
    RecapReady to give commands

    A program turns a plan into commands the robot or sprite knows. Check their order, read what each move means, and keep turns on the same square. For blocks, select the right sprite, connect its sequence, and give each run the same starting features.

2

Predict a route with a counter

11 steps
Track place and facing, then explain what changes when you change the code.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionRead before you run
  2. 2
    ExplanationKeep two things in mind
  3. 3
    ExampleFollow the first three commands
  4. 4
    ExampleFinish the same route
  5. 5
    ChallengeBack up after a turn
  6. 6
    ConnectionExplain the path with a reason
  7. 7
    ExampleChange the last move
  8. 8
    ChallengeCompare two paths
  9. 9
    TipUse a miss to choose what to check
  10. 10
    ChallengeChange a turn and trace again
  11. 11
    RecapCheck your prediction
3

Follow the clues to a bug

14 steps
Find a wrong turn, repair it, and check the whole route from the start.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionWhat did you want to happen?
  2. 2
    ExplanationName the mistake
  3. 3
    ExampleRead the tent program
  4. 4
    ChallengeName a different bug
  5. 5
    ExampleWatch the tent route begin
  6. 6
    ExampleStop at the first difference
  7. 7
    TipMake each step easier to see
  8. 8
    ChallengeFind the first wrong block
  9. 9
    ExampleChange one turn
  10. 10
    ExampleRun the whole fixed program
  11. 11
    ChallengeA later bug appears
  12. 12
    Key InsightOne change tells you more
  13. 13
    ChallengeThe code never gets a chance
  14. 14
    RecapFollow the clue, then test
4

Build a short sprite story

11 steps
Plan a character’s actions, test each part, and make the finished code easier to read.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionChoose a small story
  2. 2
    ExplanationGive every action a place
  3. 3
    ExampleTurn the first picture into code
  4. 4
    ChallengeKeep the story in order
  5. 5
    ExampleTest the journey first
  6. 6
    TipListen to a friend’s test
  7. 7
    ExampleJoin the matching moves
  8. 8
    ChallengeCheck after tidying
  9. 9
    ChallengeWhen the plan needs a fix
  10. 10
    ConnectionKeep a lesson from a bug
  11. 11
    RecapShow a working program

Sequences and Debugging practice questions

40 Practice Questions in 4 sets

Set 1: Commands, turns, and first programs10 Practice Questions

Question 1 of 10

Mia points to one instruction inside a longer robot program: "turn left". What is that instruction called?
  1. A sequence
  2. An algorithm
  3. A command
  4. A whole program
Show answerHide answer
Answer: C
A command is one instruction for the robot to follow. A sequence names the order of commands; it does not name the single instruction Mia gave.

Question 2 of 10

A floor robot faces the top of its mat. You enter turn right. Where is the robot after that command?
  1. On its start square
  2. One square right
  3. One square up the mat
  4. One square backward
Show answerHide answer
Answer: A
The robot makes a quarter turn on its start square. Its front now points right, but it has not moved right. It needs a forward command to enter the square beside it.

Question 3 of 10

A robot faces you. A token is one square to the robot’s right. What commands take it to the token?
  1. forward, turn right
  2. turn left, forward
  3. backward, turn right
  4. turn right, forward
Show answerHide answer
Answer: D
Use the robot’s right, then move forward toward the token. When it faces you, that side is on your left. Turning left follows your view instead and sends the robot the wrong way.

Question 4 of 10

You press the green flag. The turtle runs its connected blocks, but a loose "say Hi!" block sits beside them. What happens to the loose block?
  1. It runs before the others.
  2. It stays out of this run.
  3. It runs after the last block.
  4. It joins the nearest block.
Show answerHide answer
Answer: B
Only the blocks connected to this start run together. The loose speech block stays out of the sequence. Sitting beside the last block does not make it run after that block.

Question 5 of 10

A sprite starts at Home. Its connected program is "when green flag clicked", "move right 6", "say Welcome!". The app counts grid squares. What happens after you press the flag?
  1. It speaks, then moves six squares right.
  2. It moves one square right, then speaks.
  3. It moves six squares right, then speaks.
  4. It moves right while staying silent.
Show answerHide answer
Answer: C
The flag starts the sequence, then the sprite moves six squares right. The speech block comes next. Speaking first would reverse the order of the two action blocks.

Question 6 of 10

A robot faces the top of a mat. Trace forward, turn left, backward. Where does it finish compared with Start?
  1. One ahead and one left
  2. One ahead and one right
  3. One behind and one left
  4. One behind and one right
Show answerHide answer
Answer: B
The first move goes one square ahead. Turning left points the front left, so backward goes right. Moving left after that turn would follow a forward command, which is not the last command here.

Question 7 of 10

A robot faces the top. A shell is two squares ahead and two right of Start. Trace forward, turn right, forward, forward, turn left, forward. Where does it stop?
  1. On the shell, facing the top
  2. On the shell, facing right
  3. One short of the shell, facing the top
  4. One past the shell, facing right
Show answerHide answer
Answer: A
The route goes one ahead, two right, then one ahead. That reaches the shell, and the last turn makes it face the top. Keeping it facing right misses the effect of the left turn.

Question 8 of 10

A frog sprite should move five grid squares up. Its only move block says "move up 7". What kind of bug is in that block?
  1. A missing command
  2. The wrong order
  3. An extra command
  4. The wrong number
Show answerHide answer
Answer: D
The move goes the right way, but its number is too large. Change 7 to 5. An extra-command bug would involve an added block; here the mistake is inside the one move block.

Question 9 of 10

You want a sprite to wave, walk to a tent, then speak. What should your story pictures show?
  1. Walk, then wave, then speak
  2. Wave, then walk, then speak
  3. Wave, then speak, then walk
  4. Speak, then walk, then wave
Show answerHide answer
Answer: B
The pictures should keep the goal’s order of actions: wave, walk, speak. Putting speech before walking makes the character speak before it reaches the tent.

Question 10 of 10

A grid sprite starts at Home. It moves up 1 twice, says "Look!", then moves up 1 four times to a nest. What shorter program keeps the speech place, and where should its test start?
  1. move up 2, say "Look!", move up 3; test from Home.
  2. move up 6, say "Look!"; test from Home.
  3. move up 2, say "Look!", move up 4; test from the nest.
  4. move up 2, say "Look!", move up 4; test from Home.
Show answerHide answer
Answer: D
Keep the speech after two squares, so use "move up 2" before it and "move up 4" after it. Test again from Home. Joining all six moves before the speech would change where the sprite speaks.
Set 2: Follow routes and find small bugs10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

A robot understands forward, backward, and turn commands. Your plan says "visit the rug". What must you do before entering the plan?
  1. Turn the trip into commands it knows.
  2. Enter just the last forward move.
  3. Press Go before adding any commands.
  4. Use the word "rug" as a move command.
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A robot faces along a straight row toward a cup. The row is Start, blank square, blank square, blank square, cup. How many forward commands reach the cup?
  1. Three
  2. Five
  3. Four
  4. Two
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

Your sprite grows and hides during its program. The next run starts with a block that resets only its place. What else must the start of the program reset?
  1. Its place and the background
  2. Its size and whether it shows
  3. Its sound and the background
  4. Its place and its move number
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A robot faces the bottom of a mat. Trace backward, turn left, forward. Where is it compared with Start?
  1. One above and one left
  2. One below and one right
  3. One below and one left
  4. One above and one right
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A robot faces the top. Trace forward, turn right, backward, turn left, forward. What are its final place and facing?
  1. Two ahead, one left; facing the top
  2. Two ahead, one right; facing the top
  3. One ahead, two left; facing right
  4. Two ahead, one left; facing right
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

A robot should stop on a leaf two squares straight ahead. It starts correctly and runs forward, forward, forward. What bug makes it pass the leaf?
  1. A wrong turn
  2. A missing command
  3. A wrong order
  4. An extra command
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

The plan is forward, turn left, forward. The robot starts correctly but runs forward, forward, turn left. At which command does it first differ from the plan?
  1. At command 1
  2. At command 2
  3. At command 3
  4. Only after command 3
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A sprite’s goal is to move right two squares, move up three, then speak. Its connected blocks are "move right 2", "move up 4", "say Hello!" after the start. What should you inspect first?
  1. The start block, because it runs first
  2. The speech block, because it runs last
  3. The up block, where the route first differs
  4. The right block, where the journey begins
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

You found a wrong turn in the middle of a route. What should you do next?
  1. Change that turn, then test from Start.
  2. Change that turn, then test from the finish.
  3. Change both turns, then test from Start.
  4. Delete the first move, then test from Start.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Your code exactly matches your drawn route, but both miss the goal square. You have checked the robot’s start and facing. What should you check next?
  1. Whether adding a turn fixes the code
  2. Whether Go should be pressed twice
  3. Whether a different sprite has the code
  4. Whether the drawn route reaches the goal
Show answerHide answer

Save this lesson to see this answer.

Set 3: Debugging clues and careful retests10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

On your robot, new button presses join the stored program. You want to enter a fresh route. What button should you press first?
  1. Go
  2. Forward
  3. Clear
  4. Turn left
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

You added move blocks while the bird sprite was selected. You wanted the bear to move, but the bear stays still. Where should the bear’s move blocks be?
  1. In the bird’s code area
  2. In the bear’s code area
  3. In the sound choices
  4. In the background choices
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A robot faces the top. It runs forward, forward, turn right, backward, turn right, forward. Where does it end compared with Start?
  1. One ahead and one right
  2. Two ahead and one left
  3. Two ahead and one right
  4. One ahead and one left
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

Two robots start together, both facing the top. One runs forward, turn left, turn right, forward. The other runs forward, forward. How do their finish places and facings compare?
  1. Same square and same facing
  2. Same square, different facing
  3. Different squares, same facing
  4. Different squares and facing
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

In your app, "start sound" moves straight on, while "play sound until done" waits. Two different long sounds should play one after another. Both blocks are "start sound", and the sounds overlap. What fixes this?
  1. Swap the two start-sound blocks.
  2. Add another start-sound block.
  3. Use play-sound-until-done blocks.
  4. Move both blocks before the start.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

Your sprite’s moves happen too quickly to see the wrong step. What can you add between the moves to slow the run?
  1. A larger move number
  2. A second start block
  3. A loose speech block
  4. A wait block
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A robot should move two squares ahead, then two left. Its first two commands reach the right square and facing. The full run misses the target. What part should you trace next?
  1. The start square again, before reading code
  2. The later commands, beginning with command 3
  3. The first command, which must be wrong
  4. The first two commands, in reverse order
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A program has two bugs: a wrong turn, then an extra move. You fix the turn and run again from the correct start. Now it follows the planned route but passes the target. What should you do?
  1. Keep the turn fix and find the extra move.
  2. Undo the turn fix and keep the extra move.
  3. Change the start to hide the extra move.
  4. Add another turn before the extra move.
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

After you change one block, the result gets worse. What is a useful next step?
  1. Change several more blocks at once.
  2. Keep the change and move the target.
  3. Undo the change and trace again.
  4. Leave out the rest of the program.
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A robot faces the top. The mailbox is one square below Start and two right. It must finish facing right. What program meets the whole goal?
  1. forward, turn right, forward, forward
  2. backward, turn right, forward, forward
  3. turn right, forward, forward, forward
  4. backward, turn left, forward, forward
Show answerHide answer

Save this lesson to see this answer.

Set 4: Make programs work from start to finish10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

You have written code for a robot, but you have not run it. What word names the order of its commands?
  1. Prediction
  2. Debugging
  3. Sequence
  4. Testing
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A robot faces the top. A toy is two squares behind it. What commands reach the toy and leave the robot facing the top?
  1. backward, backward
  2. turn right, forward, forward
  3. forward, forward
  4. turn left, forward, forward
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A sprite needs to show the words "Good morning!" in a speech bubble. What kind of block does that job?
  1. A motion block
  2. A sound block
  3. A start block
  4. A looks block
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

A robot faces right. Trace forward, turn right, forward, turn left, backward. Where does it finish and face?
  1. One below Start, facing down
  2. One below Start, facing right
  3. One above Start, facing right
  4. One right of Start, facing down
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

A robot faces the top. It runs forward, turn right, forward, turn left, forward. You change only the first turn to turn left. Where will it now stop?
  1. Two ahead and one left
  2. Two ahead and one right
  3. One left on the start row
  4. One right on the start row
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

On a number track, start at 1. Program One moves forward 4, then forward 2. Program Two moves forward 2, then forward 4. Where do they stop?
  1. One on 5, one on 3
  2. Both on 7
  3. Both on 6
  4. One on 7, one on 6
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

A robot should go one square ahead, then one right. It starts facing ahead and runs turn right, forward, forward. What kind of bug is in this list?
  1. An extra command
  2. A missing command
  3. A wrong number
  4. The wrong order
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A sprite starts at Home, small and visible. It moves right 2 grid squares, grows, moves right 3, then hides. Its next run resets only its place. Where did the first run finish, and what else must reset for the next run to start the same?
  1. Three right; small and visible
  2. Five right; small and visible
  3. Five right; large and visible
  4. Five right; small and hidden
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

A robot’s goal names only its path and final facing. Its code is forward, turn left, turn right, forward, turn right, forward. What shorter code keeps that path and facing?
  1. forward, forward, forward
  2. forward, turn left, forward, forward
  3. forward, forward, turn right, forward
  4. turn right, forward, forward, forward
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

A sprite should move five grid squares right to a bench, then say "Sit here!". Its code after the start and reset is "move right 2", "say Sit here!", "move right 3". What feedback explains what works and what to fix?
  1. "It reaches the bench. Put the speech after both moves."
  2. "It reaches the bench. Remove the last three-square move."
  3. "It says the words. Put the speech before both moves."
  4. "It says the words. Change the first move to five."
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

45 Key Terms, each with its definition

A

Algorithm
An algorithm is a step-by-step plan for solving a problem or doing a job.
Your algorithm lists the steps for getting a robot to a flower.

B

Backward
Backward moves a floor robot one step behind itself without turning it around.
Your robot backs away from the toy but keeps facing toward it.
Block
A block is a piece of code you can drag and snap to other blocks in a block app.
You snap a speech block after the block that moves your sprite.
Bug
A bug is a mistake in code that stops a program doing what you wanted.
Your robot misses the garage because a wrong turn is a bug in its program.
Build in small parts
To build in small parts is to add a few commands and check them before adding more.
You get the blocks that move your car working before you add a speech block at the end.

C

Clear
Clear removes the stored commands on a robot that keeps them between runs.
You press Clear before entering your new route to the bridge.
Code
Code is the commands written for a robot or computer to follow.
Your code puts a move before the block that makes a sprite speak.
Coding
Coding, also called programming, means writing commands for a robot or computer.
You are coding when you snap blocks together to make a sprite hop.
Command
A command is one instruction telling a robot or computer to do one thing.
"Turn right" is a command you can give a floor robot.

D

Debugging
Debugging means finding and fixing mistakes in a program so it does the intended job.
You debug the route by changing a wrong turn, then running it again.

E

Extra command
An extra command is an unneeded instruction that makes the program differ from the plan.
An extra forward sends your robot one square past the finish.

F

Facing
A robot’s facing is the direction its front points, which guides its next forward move.
You note the robot’s facing after a turn before tracing the next move.
Feedback
Feedback tells someone what you noticed about their program and what could improve.
You say, "The car reaches the door. Put the beep after the last move."
First wrong step
The first wrong step is the earliest action that differs from your planned program behavior.
The robot turns left at step two when your route needs a right turn there.
Floor robot
A floor robot is a small robot that follows commands to move across the floor or a mat.
Your floor robot carries out the route after you press Go.
Forward
Forward moves a floor robot one step in the direction its front points.
After the robot turns left, forward takes it toward that new side.

G

Go
Go is the button that makes a floor robot run its entered program.
You enter three forward commands, then press Go to start the route.
Goal
A program’s goal is what you want it to do, including where it should finish.
Your goal is for the car to reach the garage and then beep.

L

Logical reasoning
Logical reasoning means using command meanings to work out what happens and explain why.
You explain that two forward moves reach a target two squares ahead.
Looks block
A looks block changes a sprite’s appearance or shows words in a speech bubble.
You use a looks block to make your character say "Hello!".

M

Missing command
A missing command is a needed instruction that has been left out of the code.
A missing forward makes your robot stop short on a straight path.
Motion block
A motion block is a command block that moves or turns a sprite on the screen.
A motion block takes your car three grid squares to the left.

P

Part test
A part test runs a few commands on their own so you can check that piece of the program.
You test the first three commands and check both the square and the facing.
Plan
A plan shows the steps you want to happen before you turn them into commands.
Your drawn plan shows where the robot should turn on its way to the pond.
Prediction
A prediction says what you think will happen before you run the program.
Your prediction says the robot will stop beside the tree, facing right.
Program
A program is a list of commands that a robot or computer follows to do a job.
You enter a program that takes your robot to a toy house.

Q

Quarter turn
A quarter turn turns the robot left or right by one corner, on the same square.
A robot facing the top makes a quarter turn right and now faces right.

R

Reset
To reset a sprite is to set its place or other starting features back before a new run.
You reset the sprite’s place, size, and showing after a run that changed them.
Retest
To retest is to run the program again after a change and check the result against the goal.
You retest from Start after changing the number in a move block.
Route
A route is the path a robot or sprite takes from its start toward a target.
You compare a route that goes right first with one that goes ahead first.

S

Sequence
A sequence is the order in which a program’s commands are followed.
Changing the sequence makes your sprite speak before it moves.
Sound block
A sound block makes a sprite play a sound as part of its program.
You add a sound block after the blocks that move your car so it beeps at the end.
Sprite
A sprite is a screen character or object that a program can control.
You select the boat sprite before giving it blocks to move across water.
Start block
A start block begins a connected program when its starting action happens.
Your "when green flag clicked" start block runs when you press the flag.
Step through
To step through code is to act out one command at a time and check what happens.
You step through with a partner and stop at the first wrong turn.
Story plan
A story plan puts a sprite’s actions in order, like the pictures in a comic strip.
Your story plan shows a wave, a walk to a tent, and then a greeting.

T

Target
A target is the place you want your robot or sprite to reach.
When the shell is your target, you check whether each program you try reaches it.
Testing
Testing means running a program to check that it does what you wanted.
During testing, you check where the sprite stops and listen for its sound.
Tidy code
To tidy code is to make it easier to read while keeping the actions needed for the goal.
You join three matching one-square moves into one three-square move.
Trace
To trace a program is to follow its commands one at a time and work out each action.
You trace a route with a counter, turning it when you reach a turn command.

U

Undoing turns
Undoing turns are turns that put the robot back to its earlier facing without a move.
A right turn followed straight away by a left turn undoes the change in facing.

W

Wait block
A wait block pauses the sequence before the following command runs.
You place a wait block between moves to see where your sprite goes wrong.
Wrong command
A wrong-command bug uses one instruction where a different instruction is needed.
A left turn sends your robot away from a target that needs a right turn.
Wrong number
A wrong-number bug puts a number inside a block that is too big or too small for the job.
"Move left 6" passes a target four squares left because its number is wrong.
Wrong order
A wrong-order bug puts needed commands in places that do not match the planned sequence.
Your sprite speaks before moving, but its story needs the speech afterward.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started