Activity 01
Pair Programming: Loop Showdown
Pairs select a task, such as summing even numbers in a list. First, code it with a for loop; then rewrite using a while loop. Compare run times, readability, and adaptability by testing with different list sizes, noting pros and cons in a shared document.
Compare the effectiveness of different loop types for specific programming tasks.
Facilitation TipDuring Pair Programming: Loop Showdown, sit between pairs to prompt them to vocalize their decisions, asking, 'Why did you pick a for loop here instead of a while loop?'
What to look forProvide students with two short code snippets, one using a 'for' loop and one using a 'while' loop, to solve the same simple problem (e.g., printing numbers 1-5). Ask them to write which loop they think is more appropriate for this task and why.