Grade by Grade
C. Algebra · Patterns, Equality and Coding

Coding: Step-by-Step Instructions

C3.1About 35 minutes
Learning goals
  • I know that code is a list of instructions, followed in order.
  • I can write code to move a robot on a grid.
  • I can write code to solve a math problem.
  • I can run (follow) my code to see what happens.

Words to know

code
Instructions written so a computer or robot can follow them.
instruction
One step that tells what to do.
sequence
Steps that happen one after another, in order.
run (execute)
To follow the code, step by step, to see what happens.
grid
Rows and columns of squares, like a game board.

Meet Beep the robot!

Beep is a little robot. Beep is very good at following instructions. But Beep cannot think on its own. Beep does exactly what you say, in order, one step at a time.

A list of instructions for a robot or a computer is called code. Writing code is called coding.

Steps in order: a sequence

Coding is all about doing steps in the right order. Steps that happen one after another are called a sequence.

You follow sequences every day! Here is the code for getting dressed for snow:

1. Put on snow pants
2. Put on boots
3. Put on coat
4. Put on hat
5. Put on mittens

Code for getting ready to play in the snow. Mittens go on last so your hands can do up your coat!

Order matters

What would happen if you put on your boots before your snow pants? The snow pants would not fit over the boots! In code, changing the order can change what happens.

Coding Beep on a grid

Beep lives on a grid. Beep can follow these instructions:

  • ➡ Move right (a number tells how many squares)
  • ⬅ Move left
  • ⬆ Move up
  • ⬇ Move down

Beep wants to get to the star ⭐.

Beep starts in the bottom-left square. The star is 3 squares to the right and 2 squares up. The dashed line shows Beep's path.
Worked example

Write code to reach the star

Write code to move Beep from the bottom-left square to the star.

  1. Put your finger on Beep.
  2. Count the squares to the right until you are under the star: 1, 2, 3. That is Move right 3.
  3. Count the squares up to the star: 1, 2. That is Move up 2.
  4. Write the steps in order.
  5. Run the code: move your finger right 3, then up 2. You land on the star!

The code is:

➡ Move right 3

⬆ Move up 2

START
➡ Move right 3
⬆ Move up 2
STOP ⭐

Beep's code to reach the star.

More than one way

Another code also works: ⬆ Move up 2 then ➡ Move right 3. There is often more than one correct code. Can you find a third way? (Try: Move right 1, Move up 2, Move right 2.)

Forward and turn

Some robots use Move forward and Turn instead of arrows. Forward means the way the robot's face is pointing. Pretend Beep is facing the right:

START (facing right ➡)
➡ Move forward 3
↰ Turn left (now facing up ⬆)
⬆ Move forward 2
STOP ⭐

The same path as before, written with forward and turn. A left turn makes Beep face up.

Code can do math, too!

Computers do math by following code. Here is code that counts by 5s, like counting nickels in a jar.

START with 0
Add 5
Add 5
Add 5
Add 5
SAY the number

Run it: 0 → 5 → 10 → 15 → 20. Beep says 20.

Worked example

Run the math code

What number does this code say?

START with 10 → Add 10 → Add 10 → Take away 5 → SAY the number

  1. Start with 10.
  2. Add 10: 10 + 10 = 20.
  3. Add 10: 20 + 10 = 30.
  4. Take away 5: 30 − 5 = 25.
  5. Say the number: 25.

The code says 25.

Worked example

Write code for a story problem

There are 4 children on the toboggan hill. Then 3 more come. Then 2 more come. Write code that finds how many children there are.

  1. Start with the children who were there first: START with 4.
  2. 3 more come: Add 3.
  3. 2 more come: Add 2.
  4. Tell the answer: SAY the number.
  5. Run it: 4 → 7 → 9.

START with 4 → Add 3 → Add 2 → SAY the number. The code says 9 children.

Practice grid: Beep starts in the top row, 2nd square. The star is 3 squares to the right and 2 squares down.

Your turn

1

Look at the practice grid. Write code to get Beep to the star.

2

Run this code. Start with 0, Add 2, Add 2, Add 2. What number do you get?

3

Run this code. Start with 20, Take away 10, Add 5. What number do you get?

4

Write code that starts with 0 and counts by 10s to 30.

5

Write the code for brushing your teeth in 4 steps.

6

Beep is facing right. The code says Move forward 2. Which way does Beep move?

Just for fun

What if Beep followed the snow code in a mixed-up order and put on mittens first? Beep would try to zip up its coat with big puffy mitten hands. Good luck, Beep!

Hands-on activity

Be the robot

You need: painter's tape or chalk (or floor tiles), a toy to be the "star", and paper.

  1. Make a grid on the floor, 4 squares by 4 squares. Tiles work great!
  2. A grown-up places the toy on a square.
  3. Write the code on paper with arrows, like ➡ Move right 2, ⬆ Move up 1.
  4. The grown-up is the robot. They must follow the code exactly, step by step, even if it is wrong!
  5. Did the robot reach the toy? If yes, hooray! If not, fix the code and try again.
  6. Switch: now you are the robot.

Keep trying

Coders almost never get it right the first time. That is normal! Try, check, and try again. That is how real coders work.

More practice: warm-up

1

The star is 4 squares to the right of Beep, in the same row. Write the code.

2

Run this code. START with 0 → Add 1 → Add 1 → Add 1 → SAY the number. What does it say?

3

Put these steps for planting a seed in order: Water the seed. Dig a hole. Cover it with soil. Put the seed in the hole.

4

Beep runs ⬆ Move up 3. Which way does Beep move, and how far?

5

True or false? A robot can skip a step in the code if it wants to.

More practice: on your own

1

The star is 2 squares to the left and 4 squares up from Beep. Write code to get Beep to the star.

2

Run this code. START with 10 → Add 5 → Add 5 → Take away 10 → SAY the number. What does it say?

3

There are 5 birds at the bird feeder. 4 more come. Then 2 fly away. Write code that finds how many birds are left.

4

Beep is facing up ⬆. The code says Move forward 3. Which way does Beep move?

5

Write code that starts with 0 and counts by 5s to 25.

Challenge

1

Code A: ➡ Move right 1, ⬆ Move up 3, ➡ Move right 2. Code B: ⬆ Move up 3, ➡ Move right 3. Beep starts in the same square both times. Do the two codes end in the same square? How do you know?

2

Beep starts facing right ➡. The code is Move forward 2, Turn left, Move forward 1. Where does Beep end, and which way is Beep facing?

3

Write code to go from 0 to 30 using only Add 10 and Add 5. Use as few steps as you can. How do you know it is the fewest?

Check your understanding

Quiz

1.

What is code?

2.

Beep starts at a square. The code is ➡ Move right 2, ⬆ Move up 1. Where does Beep end?

3.

What number does this code say? START with 5 → Add 5 → Add 5 → SAY the number

4.

Why does the order of steps matter in code?

5.

What number does this code say? START with 2 → Add 2 → Add 2 → Add 2 → SAY the number

6.

The star is 1 square right and 3 squares up from Beep. Which code works?

For parents and teachers

Coding in Grade 1 is about sequences: precise steps, in order. No computer is needed. The same thinking supports reading directions, math procedures and problem solving.

Common mistakes

  • Counting the starting square as a move. Show that Move right 1 means one hop to the next square. Have your child hop their finger, saying "one" as they land.
  • Mixing up left and right. A sticker or bracelet on one hand can help.
  • With forward/turn code, forgetting that turning does not move the robot, it only changes the direction it faces.

How to help

  • Play "Be the robot" often. Follow your child's code exactly, even when it leads you into a wall (they love this!).
  • Write "code" for routines: making a sandwich, getting ready for bed.
  • Free, screen-optional options: ScratchJr (app) or simple unplugged board games with arrow cards.