I’m introducing loops to my Freshmen this week. I’m trying a couple of new things. I thought I might put them out there in hopes of getting feedback but also possibly hearing how others introduce the concepts.
I’ve talked for years about the stairs. Everyone knows what happens if you don’t end your walking loop up or down stairs. We know to stop when we see that we are at the top or bottom of the stairs (while/until loops). I talk about how blind people know to count the steps in the places they regularly find themselves (for loops). It works ok.
Today I had one student count the people in the room. How did they do that? When did they know to stop? What would have happened if they double or triple counted? I need to ask how it would be different if people were moving next time. Then I had someone name three people in the room and we talked about that process some. Students haven’t thought about how they do things like this but they are basically loops.
Students seem to sometimes struggle with counters and accumulators which are commonly used with loops. Today I tried introducing them with money. Money seems to get attention. Go figure. I handed one student some coins and asked them to tell me how many coins there are. I give the same set of coins to a second student and asked them for the value of the coins. So we have a count and a total. Now we can talk about that similarities and differences in the two algorithms. It seemed to make an impact. At least everyone was paying attention.
So how do you introduce the concept of loops? What sort of real life examples do you use? Please share what works for you. I have a new class in three weeks and I want to get better.