Use popular, repetitive music to teach loops in a beginning course because this motivates the purpose and application of loops while keeping students engaged by referencing popular culture.

  • Activity:
    • Start the class with a catchy, repetitive top-20 song.
      • You can sing it to the get the class extremely engaged.
        • This is really helpful so that students can see a less serious side of you.
      • Alternatively, you can play the song on YouTube.
    • Introduce loops by showing students how a loop could be used to print out a repeated lyric the correct number of time.
      • Show students code that will write the repetitive loop the correct number of times.
    • Now, ask students to pick out their own catchy song with lyrics that repeat.
      • Suggest Happy Birthday to students who need an easier song to start with or cannot come up with a song of their own.
    • Have try to write code that prints out chorus in as few lines as possible.
    • Extend the activity:
      • Introduce nested loops using songs that have repeated lyrics within the larger repetitive chorus.

More about this tip

External Source

Interview with Mark Zarb

Other Tips By