Getting "Loopy" in Computer Science

Right now in Computer Science/ Coding we are learning about a very powerful tool – loops. Loops describe when we repeat an action for every item in a group or while a certain condition is true. Thus, we have two types of loops when programming with Python – for loops and while loops.

It can be helpful to think of loops in our everyday lives. Take icing cupcakes, for example. You bake 24 cupcakes and put icing on one cupcake at a time until you have iced all 24 cupcakes. Or you add pictures to Facebook and go through each one tagging your friends’ and family members’ faces until you get through all of the pictures. Both of these are examples of for loopsFor each item in the group (cupcakes, pictures, etc.), something happens to the item (the cupcake gets iced, the picture gets tagged, etc.).

While loops are a little different. A while loop only runs while a condition is true. For example, while your treadmill is on, it will keep running (even if you don’t!). When playing bridge, poker, or some other card game, you deal cards until each player has the appropriate number of cards. The words while and until are good clues that a while loop is at play in these situations.

We spent most of February and March cutting our teeth on for loops, and this month we are delving into while loops. Both of these are very powerful tools for programmers, and our students have made tremendous progress in their ability to understand how they work and create basic loops.

At this stage, most of our students can set up a for loop and explain what the computer is doing at each line. Soon, they will be able to do the same with while loops. The next step for them as programmers is to marry their newfound technical knowledge with critical thinking and problem solving. This is the goal of the challenges we often do during CS/ Coding time. Each challenge is an opportunity for them to perform a critical analysis, develop a strategy, apply the tools they have to the challenge, and test their own work. As Erin at Google told our Long-View kids, how they think is more important than what language they know.