Skip to content

For KidsBuild and Program

Programs, Steps and Loops

A program is a list of steps the robot follows in order; a loop repeats steps.

Not started Jump to practice

A robot does not understand "go to the kitchen." It understands small steps, done in order, exactly.

Key idea

A program is a list of steps that a computer follows in order. A loop repeats some steps. In block coding, each step is a block you snap together, like a puzzle.
Step through the program and watch the robot follow each block. Then try the other programs.

Why it works

Grown-up programmers do the same thing in typed code. Breaking a big job into small, exact steps is the most important skill in programming.

Let's think it through

Worked example: Follow the steps

A robot faces right. Its program: forward, forward, turn left, forward. How many squares has it moved, and which way does it face at the end?
  1. Forward, forward: 2 squares right.
  2. Turn left: it now faces up. Turning does not move it.
  3. Forward: 1 square up.

Answer: 3 squares moved; it faces up.

Worked example: Use a loop

Write a shorter program for: forward, turn right, forward, turn right, forward, turn right, forward, turn right.
  1. Find the part that repeats: forward, turn right.
  2. It repeats 4 times.

Answer: Repeat 4 times: [forward, turn right]. The robot drives in a square.

Common mistake

Counting a turn as a move. A turn changes which way the robot faces, but it stays on the same square.

Try it at home: program a grown-up

Write a program on paper to make a peanut butter sandwich, then have a grown-up follow it exactly, doing only what the words say. "Put peanut butter on bread" might end with the whole jar on the loaf. Fix your program and try again. Free block-coding sites such as Scratch let you program on-screen sprites the same way.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 1 XP.

Loading practice…

Builds on

Leads to

Sources and further reading