Teaching loops and efficiency

How do you teach the core computer concept of loops to your students?

Share your best practices, hacks, tips and tricks here. Also feel free to share here your questions, half-baked ideas, spectacular failures and concerns about teaching loops.

In your post, be sure to tell us what grade you teach and any other relevant information about your classroom context that will help other understand how they might implement your idea.

4 Likes

Here are some resources from the code.org Code Studio curriculum focused on teaching loops:
Take a moment now to review how loops are introduced in the code.org curriculum. As you explore the resources below, consider how you might implement the suggested activities in your classroom.

Unplugged Lesson Plans

“Getting Loopy” Lesson Plan: Course 1, Course 2

Code Studio Activities

Explore Course 1 loop stages:

Explore Course 2 loop stages:

With my younger students I do a very simple activity to show how loops are “easier.” I have one student stand in the middle of the room all the way in the back. I tell them to follow my directions. I say “student name take one step forward.” I literally repeat that same line about 15/20 times. As I get to the 10th, 11th, 12th time saying it I act so tired. I am taking bigger breaths and my body language is hunched over because I am sooooo tired. Eventually the student reaches me and I am just so tired and out of breath I can’t teach anymore. I ask the students to explain why I am so tired. I then ask them to figure out a way to make my directions easier. They soon start reenacting the steps taken and begin counting how many were taken. Eventually, they determine a much easier way to give the directions and they are so excited to tell me that I should have said “student name take 15 steps forward.”

15 Likes

This looks like something we could use in math demonstrating how repeated addition is the same as multiplication.

9 Likes

When teaching students in grades K-5 one way to explain the concepts of loops is to demonstrate how efficient they are and how they are already familiar with them using examples such as in music or even the race track. It is usually not a challenging concept for them to grasp. When the concept of loops is introduced to them in the on-line courses some students may remark that they should have been introduced the loop block much earlier because it is so much easier for them to do after trying to manage so many individual blocks as the desired outcome becomes more complex.

2 Likes

With loops, I have used robotics to illustrate this. In order for the robot to travel in a square, it has to travel in a straight line and turn 90 degrees over and over again. By having students program the robot using what they already know, when I show them a loop, it is easy for them to see how using looping is preferable to a long list of repeated directions.

I like the idea of having students identify directions for things they do in their everyday school lives that could be simplified through the use of loops. I would have them make the “L” sign with their fingers at any time they feel they have identified a potential for loops. They love having ‘secret’ signs that mean something special to our class.

Love the Simon Says type of activity also - it is a great opportunity for dramatic interpretation on the part of the teacher!

2 Likes

I have heard a similar gripe from students when learning different kinds of sorts, for example, the bubble sort feels super tedious when you first learn it, and then later you learn other sorting methods that are much faster and more efficient. Students have asked, “Why did we have to learn the bubble sort if computers don’t use it anymore?”

How do you handle these sorts of “why bother?” questions when you’re introducing simple concepts to teach the basics of CS?

I like the idea of using the ‘Getting Looping’ unplugged lesson to introduce students to the concept of loops. I plan to use that with my Kindergarten students. Think they will love it!

I like to show how our procedures in our classroom are loops. For example every time I wash my hands I… or every time we walk into the classroom we … Although it doesn’t loop immediately it is something that is repeated over and over again everyday. It introduces the concept. We also do activities where we come up with activities that are repeated over and over again.

2 Likes

I plan on using my Duplo railroad track - I have enough track to do a loop with two Y tracks to leave the loop when done.

I also like Getting Loopy. It will get the kids moving!

I really like the Getting Loopy lesson. I’m sure my students will love watching me attempt to do it and they’ll enjoy doing it themselves! One way I’ll incorporate loops is by explaining how our routines can be considered as loops. Each day we get up and get ready for school, go to school, follow a certain schedule throughout the day, and go home. There are differences in each day, but when we’re in school the days follow a particular pattern. Long division is a loop. We divide, multiply, subtract, bring down, and repeat until complete. Baseball games contain a series of loops, as do most games. There are quite a few examples–the key is finding the best ones to which our students can relate.

1 Like

When teaching about loops, I explained how in multiplication, it’s a loop of addition.
2x5 is really repeating adding 2 five different times.

1 Like

I’ve teamed with our phys. ed. teacher when teaching loops. She can easily show the children loops with repetitive movements - jumping jacks, push ups, etc. They catch on quickly and the kids love CS vocab in gym!

2 Likes

I use the clearing the table after you eat and washing dishes. “Pick up plate, take it to the sink, set it down, go back to table. Pick up plate (glass, silverware, etc), take it to the sink, set it down, go back to table…” Or, “pick up plate, rinse it, put it into dishwasher. Pick up plate, rinse it, put it into dishwasher.” I try to do something that all students would have experience with. Making bed, cleaning room, brushing hair or teeth…

1 Like

Often when students dive into the depths of a Minecraft world they will create a staircase that leads down to the lower levels. This staircase they create is a series of repeating steps. Dig down, dig forward, dig down, dig forward, place torch…repeat.

Seems this would be a perfect connection to looping.

3 Likes

I think it goes back to learning the word algorithm. It is a specific set of instructions that tells us what to do and how to do it the right way. Simply try explaining to the students that we have to learn all of the individual steps before we can find the “secrets” that help to make things easier. I’m sure you will always get the gripes, but as least they might see that they needed all of the steps before they could start finding the cool tricks!

A popular song is a great way to teach loops. The teacher could share an example and then put students in groups to come with a song and sharing where the song loops.

Again, this is with kindergarten, first and second grades. We discuss loops in our own lives. Get up, get dressed, eat breakfast, go to school, come home, play, put on pj’s, go to bed. (Later, you can add on conditionals to this script: if weekday, then this loop, else watch cartoons, go to soccer, etc.). We discuss smaller loops: eating something (bring to mouth, bite, chew swallow, repeat until…), walking (right foot forward, left foot forward).
Then I put several “scripts” with loops on the board or floor and they follow them. For example: jump, clap, bend, jump, clap, bend, jump, clap, bend. Then written this way: 3(jump, clap, bend) We discuss which is easy to read and execute. Then they write loops of their own on cards and act them out.

1 Like

I going to use some workout dance . Here we have to repeat over and over the same steps . The same from the beginning:)