Want to learn about Loops? All you need to do is Floss

Updated: Aug 18, 2021

One really cool thing that we like to do as we learn programming fundamentals, is to relate them back to the real-world. The concepts become much easier to understand this way.


This week's topic, Loops, got us up away from our keyboards as we put this topic into action.


But first, we need to understand what a loop is.

In programming, a Loop is a repeated action
Girl with a hula hoop
A hula LOOP

Some real-world examples we talked about include the water cycle, running laps, spinning a hula hoop, and your kid brother asking "Are we there yet?!" every five minutes on a road trip.


We energized this programming concept by turning up the music and working out our algorithm for flossing. Oh, not dental flossing, but come to think of it, that's a Loop, too!

Cartoon unicorn doing The Floss dance
Flossing is for unicorns too

We came up with the steps to do the popular dance, The Floss.

  1. Place your hands out in front of you like you are holding a stick

  2. Bring your hands down towards your hip, and turn your arms out

  3. Now, bring your hips out and your hands down - as if you are breaking the stick with your hip

  4. Bring your arms back up and your hips back to neutral - as if you are pulling the stick back out

  5. Switch your arms to the other side

  6. Break the stick with your hip

  7. Pull the stick back out

  8. Switch sides

  9. Break the stick with your hip

  10. Pull the stick back out

  11. Switch sides

Are you seeing the pattern?

Yeah, that's right - steps 3, 4 & 5 are a Repeated Action. We've found our LOOP!

Doing The Floss, now looks like this:

  1. Place your hands out in front of you like you are holding a stick

  2. Bring your hands down towards your hip, and turn your arms out

  3. REPEAT UNTIL THE SONG ENDS

  4. Break the stick with your hip

  5. Pull the stick back out

  6. Switch sides

Our junior programmers put this concept into practice and quickly mastered it. You can really see how using a Loop statement in code can streamline and reduce the amount of code you need to write.


In our Blockly toolbox, we use the Repeat block to do the work for us.

Multiple lines of code streamlined by using a Loop statement
The power of a LOOP!

The feedback from our junior programmers sums it up for us:

"I found the pattern, now let me use my repeat loop"
"These Loops are so eeeasy!"




24 views1 comment

Recent Posts

See All