STEM activities: Why coding loops are so important
Programming tutorials for all ages, from Robotics & Beyond.
Hi! I’m journalist Caroline Delbert and this is The Toolkit from Robotics & Beyond 501(c)3. Our goal every week is to give you some videos, projects, and products that help kids (and parents) get inspired by science, technology, engineering, math, and creative design.
This week in issue 7 we’re going to talk about loops. A loop is a fundamental part of the structure of coding, and we use them in pretty much every programming language used by schools and computer science departments. (Even in COBOL, a 60-year-old batch and mainframe language that still runs most of the world’s ATMs, for example, there’s a way to do loops. Also, don’t mistake COBOL’s age for irrelevance.)
Short list:
Ages 5-8: Loop explanation (video)
Ages 8-12: Intro to programming loops (video)
Ages 12-15: What are loops? (video)
Bonus: Fish hat!
Why are loops so important in code?
As one of our videos below puts it, life is full of repeating routines: We wake up each day, we brush our teeth, we shower and get dressed. Someone watching our lives on fast forward might get the impression that sometimes the same days are being repeated verbatim. But in programming, too, loops allow for conditions that change things. All a loop refers to is the structure of a piece of code that allows it to be repeated, whether that’s with an advancing counter (doing something x times) or until a particular condition is met.
You think in a “loopy” way every day, like putting on shoes — and which shoes you put on depends on conditions like where you plan to go and what the weather may be like. Even something like the alarms you can set up on your smartphone use loops, and you can set the alarm to only go off on days that meet certain criteria. Loops are everywhere.
In another of the videos below, the narrator explains that the best mathematicians are lazy. This is a common joke, but it’s also true, and it applies to coders. Why would you, for example, write out the same piece of calculation or function dozens of times? Instead, you can write it one time and let the code “call” it again and again as they need it. Loops are a way to save a lot of time, and it’s also much easier to fix just one piece of code than to seek out the same error you may have made a dozen times. A stitch in time saves nine, right?
Ages 5-8: What Are Loops? (4 min)
For young kids, this video from coding education startup Kodable breaks down how setting the table would become an unwieldy programming task very quickly without loops. “Loops are about keeping your code DRY,” the narrator explains. “DRY means Don’t Repeat Yourself.” One could argue this is the fundamental idea in the way we program today.
Ages 8-12: Intro to Programming: Loops (3 min)
From Codecademy, this great video explains reasons why loops are important — including the fact that programmers need to be able to turn great pieces of code into reusable functions instead of just pasting the same code again and again. A calculator is a great example of something where we call functions, because pressing + or × calls the function to do each operation, and the calculator takes the numbers we’ve typed in as the parameters for the function.
Ages 12-15: What Are Loops? (9 min)
Something I really like about educator Andy Wicks’ video is that he’s still talking in general terms — we’re talking about what loops are and what they do — but he’s not teaching it in Java or C++ or anything. Instead, he uses examples like the fact that computers can’t multiply to illustrate principles that influence looping structures. Multiplying is just looping addition until we reach our goal.
(Last week’s newsletter was: Why you shouldn’t sell yourself short as a STEM teacher, even if you hate math.)
Forward this email to anyone who you think might enjoy it!
Get in touch: Contact us at toolkitnewsletter@gmail.com
Wow that’s cool! I’m sorry but I just can’t stop watching this man explain how to wear a corrugated paper fish (vase?) as a hat.