Activity 01
Pair Programming: Loop Comparisons
Pairs receive a task like summing a list of numbers. First, code it with a while loop using a counter; then rewrite with a for loop. Discuss differences in structure, readability, and when to use each. Test both versions with varied inputs.
Compare the appropriate use cases for 'while' loops versus 'for' loops.
Facilitation TipDuring Pair Programming: Loop Comparisons, ask pairs to switch roles after every 5 minutes to keep both partners engaged with loop logic.
What to look forPresent students with two short code snippets, one using a 'while' loop and one using a 'for' loop, both achieving the same result (e.g., printing numbers 1-5). Ask students to identify which loop is more appropriate for the task and explain why in one sentence.