Activity 01
Pair Programming: Loop Comparisons
Pairs code two versions of a program to calculate list averages, one with a 'for' loop and one with a 'while' loop. They test inputs, compare run times using timers, and discuss when each loop suits the task. Switch roles for a second challenge.
Evaluate the consequences of an infinite loop in a resource-constrained environment.
Facilitation TipDuring Pair Programming: Loop Comparisons, assign distinct roles to each student and rotate them halfway so both experience designing and testing loops.
What to look forProvide students with two short code snippets, one using a 'for' loop and one using a 'while' loop, both solving a similar problem (e.g., printing numbers 1-10). Ask them to write one sentence explaining which loop is more appropriate for a task where the number of repetitions is unknown and why.