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
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!
We came up with the steps to do the popular dance, The Floss.
Place your hands out in front of you like you are holding a stick
Bring your hands down towards your hip, and turn your arms out
Now, bring your hips out and your hands down - as if you are breaking the stick with your hip
Bring your arms back up and your hips back to neutral - as if you are pulling the stick back out
Switch your arms to the other side
Break the stick with your hip
Pull the stick back out
Switch sides
Break the stick with your hip
Pull the stick back out
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:
Place your hands out in front of you like you are holding a stick
Bring your hands down towards your hip, and turn your arms out
REPEAT UNTIL THE SONG ENDS
Break the stick with your hip
Pull the stick back out
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.
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!"
What a unique way to break down the loop concept and having the kids understand it and put it in action!! Looking forward to the next blog!