# How to Explain Loops to Kids

How to Explain Loops to Kids

# How to Explain Loops to Kids

Sometimes we take for granted the ability to instruct someone to repeat an action, rather than needing to tell them to perform each individual action. Imagine having to tell someone, “Set this plate on the table, then set this plate on the table, then set this plate on the table…” instead of simply saying, “Set the table for four.”

Computers require very specific instructions to perform their tasks: Unlike humans having a conversation, computers can’t pick up information based on context, tone, or body language.  To repeat an action a hundred times, it would require having to write a hundred lines of code to repeat the action! Fortunately, there is a way to tell a computer to repeat an action without writing a separate line of code for each repetition. This concept is called a “loop,” and similar to other programming ideas like algorithms, there are fun ways to teach it at home! There are two kinds of loops: “counting” loops and “conditional” loops. Below are examples of activities you can do at home to teach your child about both kinds of loops!

### Counting Loops: Brushing Your Teeth

We use counting loops when we want to tell the computer to repeat an action a certain number of times. Let’s take a look at how to apply counting loops to brushing your teeth:

-Bring a whiteboard and marker (or paper and pen) into the bathroom when it’s time for your child to brush her teeth.

-Ask: “Are there any steps we repeat?” Perhaps your child will mention that we should brush our tongue several times at the end of the routine.

-Say: “Pretend we’re writing instructions for someone who’s never brushed their teeth before. We have to write each action by itself on a line. How would we tell them to brush their tongue 3 times?” (Depending on your child’s understanding, she may be able to figure out how to write the instructions with some guidance from you. Or, you can write while your child gives you the answers. Remember that if your child writes the answers themselves, they’ll be more likely to remember what they learn, so it’s a good idea to have them write as much as they can.)

-The end result should look like this:

brush tongue
brush tongue
brush tongue

-Say: “Can you think of a word that means to do something more than once?” (“Repeat”)

-Write:

Repeat

-Say: “What action do we need to repeat?” (Brush tongue)

Repeat

brush tongue

-Say: “How many times do you brush your tongue?” (3)

Repeat [3 times]

brush tongue

-Explain to your child that together you just wrote a counting loop–a set of instructions telling someone to repeat a sequence of actions.

-Have your child brush their teeth. Can they think of any other steps that repeat?

### Conditional Loops: Dance Party!

A conditional loop is a loop that tells a computer to repeat a sequence of actions until a condition is met. Follow these steps to teach your child how to use conditional loops:

-Write or have your child write the following instructions on a whiteboard:

clap
step left
step right

-Say: “We’re going to pretend we are computers, and these are our instructions.”

-Say: “We need to keep performing these instructions over and over.” (Repeat motions several times.)

-Say: “We need to know when to stop. We will stop when we’re tired.”

-Write:

Repeat [until I’m tired]

clap
step left
step right

-Say: “Now we can dance and stop when we’re tired!”
-Say: We just made a conditional loop. In computer languages, conditional loops tell the computer to perform an action until something happens. In our case, that something is until I’m tired. When that happens, you can stop dancing.

-Dance until you get tired to reinforce your child’s understanding of this concept!

Kids learn programming concepts like loops, algorithms, pattern recognition, and more when they code with Tynker! With our full range of learn-to-code solutions, including Tynker Junior and coding courses for real-world languages like Python and JavaScript, there’s something for your child, whatever their level! Learn more about our 2,000+ coding activities from Minecraft to Barbie!

Tynker enables children to learn computer programming in a fun and imaginative way. More than 60 million kids worldwide have started learning to code using Tynker.