Activity 01
Pair Programming: Square Builder
Pairs write a list comprehension to generate squares for numbers 1 to 10, then rewrite using a for loop. They run both in an IDE, compare line count and readability, and discuss advantages. Extend to cubes.
Explain how list comprehensions can simplify code for creating lists.
Facilitation TipDuring Pair Programming: Square Builder, encourage pairs to swap roles after each line so both students practice writing and interpreting syntax together.
What to look forProvide students with the following prompt: 'Write a list comprehension to create a list of all even numbers between 20 and 50. Then, write the equivalent code using a traditional for loop. Briefly explain which version you find easier to read and why.'