Activity 01
Pair Programming: Scope Refactor Challenge
Pairs start with a simple program heavy on global variables, like a basic quiz scorer. They identify access risks, convert globals to locals where safe, and add functions that share state carefully. Test changes and discuss improvements before sharing with the class.
What are the risks of using global variables compared to local variables within a program?
Facilitation TipDuring the Pair Programming refactor, insist each pair writes a one-sentence rule for every change they make to reduce global use.
What to look forPresent students with a short Python code snippet containing both local and global variables. Ask them to predict the output of the program and explain their reasoning, focusing on where each variable is accessible.