Grade by GradeEssential student suppliesSign in
CS. Computer Science · Computer Science: Order and Follow Instructions

Computer Programs Follow Steps

AB SC 1: computer programs AB SC 1: specific orderAbout 30 minutes
Learning goals
  • I can tell what a computer program is.
  • I can follow a three-step program exactly, like a computer.
  • I can tell what happens when the steps of a program are out of order.

Words to know

computer
A machine that follows instructions to do jobs.
program
A list of instructions for a computer, in order.
programmer
A person who writes programs. Programmers are also called coders.
bug
A mistake in a program.

Computers need instructions

A computer cannot think up what to do by itself. People give it instructions. A list of instructions for a computer is called a program, or code.

Computers are inside many things: tablets, video games, some toys, cars and vending machines.

A computer does exactly what the program says, in the order it says. It does not guess. It does not skip a step. So the order of steps in a program is very important.

Worked example

The snack machine program

A vending machine at a rec centre in Airdrie has a computer inside. Its program is:

  1. Wait for money.
  2. Drop the snack.
  3. Give back the change.

What happens if a programmer swaps steps 1 and 2 by mistake?

  1. In the right order, the machine waits for money, then drops a snack, then gives change.
  2. In the swapped order, the machine drops a snack first, before anyone pays.
  3. The computer does not know this is wrong. It just follows the steps.

The machine gives away snacks for free! The swapped order is a bug.

1. Wait for money.
2. Drop the snack.
3. Give back the change.

The snack machine's program, in the right order.

Be the computer

You can follow a program just like a computer, with no device at all. You only need paper and a crayon.

Here is a drawing program:

  1. Draw a big square.
  2. Draw a triangle on top of the square.
  3. Draw a door inside the square.

A computer would follow each step exactly. The outcome is a little house.

The drawing program, step by step1. Draw a square.2. Add a triangle on top.3. Add a door inside.
Each step of the program adds one shape. After step 3, the outcome is a house.
Worked example

A bug in the drawing program

Ben's program has the steps in this order:

  1. Draw a door inside the square.
  2. Draw a big square.
  3. Draw a triangle on top of the square.

What happens when Maria follows it exactly, like a computer?

  1. Step 1 says to draw a door inside the square. There is no square yet!
  2. A computer cannot follow a step that does not make sense. It gets stuck or does something odd.
  3. Ben fixes the bug by moving the square step to the front.

The program has a bug. Square first, then triangle, then door gives a house.

ProgramRight order?Outcome
square, triangle, dooryesa house
door, square, trianglenostuck at step 1
money, snack, changeyespeople pay, then get a snack
snack, money, changenofree snacks!
When a program's steps are in the wrong order, the outcome changes.

Exactly, like a computer

When you play "be the computer", do only what the step says. Do not add extra things. This shows you if the program is clear and in the right order.

Odd fact

Long ago, the word computer meant a person! People whose job was to work out lots of math by hand were called computers. Later, the name was given to the machines.

Hands-on activity

Be the drawing computer

You need: paper and crayons.

  1. Your grown-up writes a 3-step drawing program, like: draw a big circle, draw two dots inside the circle, draw a smile under the dots.
  2. You are the computer. Follow each step exactly.
  3. Look at the outcome. Is it what the program wanted?
  4. Now swap two steps and try again. Does the drawing still work?
  5. Switch: you write a 3-step program for your grown-up.

Using a device? Some coding apps for young children let you put steps in order on a screen. Only use one with a grown-up. The grown-up sets it up. Do not type your real name, school or address, do not add a photo of yourself, and do not chat with people you do not know.

Your turn

1

What is a program?

2

Does a computer guess what you mean?

3

What did the swapped snack machine program do?

4

What is the first step of the drawing program for a house?

5

Why did Ben's program get stuck?

6

What is a mistake in a program called?

More practice

1

Name two things that have a computer inside.

2

What is another name for a programmer?

3

Put in order: draw two dots inside the circle, draw a big circle, draw a smile under the dots.

4

What did the word computer mean long ago?

5

Name one way to stay safe with a coding app.

Check your understanding

Quiz

1.

What is a computer program?

2.

How does a computer follow a program?

3.

The snack machine drops a snack before anyone pays. Why?

4.

Which drawing program makes a house?

For parents and teachers

How to help at home:

  • "Be the computer" games need no screen. Take turns writing and following tiny programs, and follow them literally.
  • When a program fails, praise the fix: finding and fixing bugs is a real part of coding.
  • If you use a coding app, choose one made for young children, set it up yourself, use a nickname rather than a real name, turn off chat and sharing, and stay with your child.

Common mistakes:

  • Following what was meant, not what was written. The point of the game is to follow steps exactly.
  • Thinking computers are smart on their own. Computers only follow instructions people give them.