Activity 01
Debugging Challenge: Global Variable Hunt
Provide pairs with a buggy program using excessive globals causing errors. Students trace execution, identify issues, and rewrite with locals. Discuss fixes as a class.
Explain how local and global variables affect the integrity and predictability of a program.
Facilitation TipDuring Global Variable Hunt, ask students to trace globals step-by-step aloud, forcing them to verbalize their assumptions before testing.
What to look forProvide students with a short Python code snippet containing both local and global variables. Ask them to identify which variables are global and which are local, and predict the output of the program, explaining their reasoning for each variable's value.