Activity 01
Pair Refactoring Challenge: Modularise a Calculator
Provide students with a linear script for a basic calculator. In pairs, identify repeated operations and refactor them into functions with parameters. Test the modular version by adding a new operation and compare debugging time to the original.
Analyze the benefits of using functions for code organization and debugging.
Facilitation TipDuring the Pair Refactoring Challenge, circulate and ask each pair to verbally explain why they chose specific functions before they write any code, forcing early design thinking.
What to look forProvide students with a short Python code snippet containing a simple function. Ask them to identify the function name, its parameters (if any), and the arguments passed when it's called. Then, ask them to write one sentence explaining what the function does.