Learn Without Walls
← Previous Lesson Lesson 2 of 4 Next Lesson →

Lesson 2: Giving Good Instructions

About 15-20 minutes -- Screen-free lesson

What You Will Learn

By the end of this lesson, you will be able to:

Why Being Specific Matters

In Lesson 1, you learned that computers follow instructions. But here is the tricky part: computers need instructions to be very, very specific. If an instruction is unclear, a computer cannot guess what you meant. It will either do the wrong thing or stop working entirely.

People are good at figuring out what someone probably means, even if the instructions are not perfect. But computers cannot do that. They take everything literally.

Ambiguity: When something could mean more than one thing. Computers cannot handle ambiguity. They need instructions that have only one possible meaning.

An Ambiguous Instruction

Imagine you tell someone: "Draw a big circle."

That sounds simple, right? But think about all the questions that instruction does not answer:

  • How big is "big"? As big as a coin? As big as a basketball? As big as the whole page?
  • Where should the circle go? In the middle of the page? The top left corner?
  • What color should it be?
  • Should it be filled in or just an outline?

A person might guess reasonable answers to these questions. A computer cannot.

The Peanut Butter Sandwich Challenge

This is one of the most famous activities for learning about instructions. It is silly, messy, and will teach your child something they will never forget.

Unplugged Activity: Make a Peanut Butter Sandwich

What you need: Bread, peanut butter (or any spread), a butter knife, and a plate. Optional: jelly or jam.

How to play:

  1. Tell your child: "I am going to be a computer. You need to tell me how to make a peanut butter sandwich. I will do exactly what you say -- nothing more, nothing less."
  2. Your child gives you instructions, one step at a time.
  3. You follow each instruction as literally as possible.

The key rule for the parent: Do exactly what the words say, not what you think they mean.

Examples of taking instructions literally:

  • "Put the peanut butter on the bread" -- Put the whole jar on top of the bread.
  • "Open the bread" -- Try to open the bag by pulling it apart, since they did not say how to open it.
  • "Spread the peanut butter" -- Spread it with your hand (they did not say to use a knife!).
  • "Put the bread together" -- Stack all the slices on top of each other.

Let your child keep trying to fix their instructions until they finally get it right. The goal is laughter and learning, not a perfect sandwich on the first try!

Talk About It

After the activity, ask your child:

  • "What was the hardest part about giving me instructions?"
  • "What happened when your instructions were not specific enough?"
  • "How is this like giving instructions to a computer?"

The big lesson: computers are just like the parent in this game. They do exactly what you tell them, even if it is not what you meant.

Common Mistakes in Instructions

When people write instructions, they often make the same kinds of mistakes. Learning to spot these mistakes will help you become a better thinker and a better coder.

Mistake 1: Skipping Steps

Bad instructions for drawing a house:

  1. Draw a square.
  2. Draw a triangle on top for the roof.
  3. You are done!

Wait -- what about the door? The windows? Where on the paper should the house go? How big should it be? Many steps are missing.

Mistake 2: Being Too Vague

Bad instruction: "Put some water in the cup."

Better instruction: "Fill the cup with water until the water reaches the line marked on the side."

The word "some" is vague. How much is "some"? A tiny drop? The whole cup? Be specific!

Mistake 3: Wrong Order

Bad instructions for getting dressed:

  1. Put on your shoes.
  2. Put on your socks.
  3. Put on your pants.

Try putting shoes on before socks! These steps are in the wrong order.

Mistake 4: Assuming Knowledge

Bad instruction: "Save the file in the usual place."

A computer does not know what "the usual place" means. It has no memory of what you have done before (unless someone programmed that in). You need to tell it exactly where to save the file.

Practice: Fix These Instructions

Try It: Can You Spot the Problems?

These instructions for brushing your teeth have problems. Can you find them and write better instructions?

  1. Put toothpaste on the brush.
  2. Brush your teeth.
  3. Rinse.

Problems: Step 1 does not say to pick up the toothbrush first or open the toothpaste. Step 2 is too vague (which teeth? how long?). Step 3 does not say what to rinse or how.

Better instructions:

  1. Pick up your toothbrush with one hand.
  2. Pick up the toothpaste tube with the other hand.
  3. Take the cap off the toothpaste.
  4. Squeeze a pea-sized amount of toothpaste onto the bristles of the toothbrush.
  5. Put the cap back on the toothpaste and set it down.
  6. Put the toothbrush in your mouth.
  7. Brush the front of your top teeth for 15 seconds.
  8. Brush the front of your bottom teeth for 15 seconds.
  9. Brush the chewing surfaces of your teeth for 15 seconds.
  10. Brush the back of all your teeth for 15 seconds.
  11. Spit the toothpaste into the sink.
  12. Turn on the water faucet.
  13. Rinse your toothbrush under the water.
  14. Cup water in your hands and rinse your mouth.
  15. Spit the water into the sink.
  16. Turn off the water faucet.

That is a lot more steps! But now a "computer" could follow these instructions perfectly.

Try It: Fill in the Missing Steps

These instructions for pouring a glass of juice are missing some steps. What is missing?

  1. Open the refrigerator.
  2. _______________
  3. Close the refrigerator.
  4. _______________
  5. Open the juice carton.
  6. Pour juice into the glass until it is three-quarters full.
  7. _______________
  8. Put the juice carton back in the refrigerator.
  1. Open the refrigerator.
  2. Take out the juice carton.
  3. Close the refrigerator.
  4. Get a glass from the cabinet.
  5. Open the juice carton.
  6. Pour juice into the glass until it is three-quarters full.
  7. Close the juice carton.
  8. Put the juice carton back in the refrigerator.

How This Connects to Coding

Everything you have practiced in this lesson is exactly what programmers do every day. When you write code for a computer, you are writing a list of very specific instructions. If even one instruction is unclear or in the wrong order, the program will not work correctly.

Programmers call mistakes in their code bugs. Many bugs happen because the programmer assumed the computer would understand something that was not clearly spelled out. Just like the peanut butter sandwich game!

Bug: A mistake in a computer program that causes it to do something unexpected or wrong. The word "bug" has been used this way since the 1940s.

Debugging: Finding and fixing bugs in a program. This is one of the most important skills a programmer can have.

Talk About It

Ask your child: "In the peanut butter sandwich game, when I did the wrong thing because your instructions were not clear, were you debugging? What did you do to fix it?" Help them see that they were already thinking like a programmer!

Rules for Writing Good Instructions

Here are four rules that will help you write great instructions, whether for a person or for a computer:

Rule 1: One Step at a Time

Each instruction should describe just one action. Instead of "Open the jar and spread the peanut butter," split it into two steps.

Rule 2: Be Specific

Avoid words like "some," "a little," "over there," or "the usual way." Say exactly what, where, and how much.

Rule 3: Use the Right Order

Think about what needs to happen first. You cannot spread peanut butter before opening the jar.

Rule 4: Do Not Skip Steps

Include every step, even ones that seem obvious. Remember, a computer does not know what is "obvious."

Check Your Understanding

1. What does "ambiguity" mean, and why is it a problem for computers?

Answer: Ambiguity means something could mean more than one thing. Computers cannot handle ambiguity because they cannot guess what you meant. They need every instruction to have exactly one clear meaning.

2. What are the four rules for writing good instructions?

Answer: (1) One step at a time, (2) Be specific, (3) Use the right order, and (4) Do not skip steps.

3. What is a "bug" in programming?

Answer: A bug is a mistake in a computer program that causes it to do something unexpected or wrong. Finding and fixing bugs is called debugging.

Key Takeaways

Ready for More?

Next Lesson

In Lesson 3, you will play the Robot Game! Your parent becomes a robot and you give them instructions to complete fun challenges.

Start Lesson 3

Module Progress

You have finished Lesson 2! Two more lessons to go.