Activity 01
Pair Programming: Shape Calculator Functions
Pairs write three functions: one for circle area, one for rectangle area, and one to compare results. They call each with user inputs and refactor a script with repeated calculations. Pairs swap code to test and suggest improvements.
Analyze how functions reduce code redundancy and improve modularity.
Facilitation TipDuring Pair Programming, circulate and ask each pair to explain why they chose a particular parameter name, reinforcing the connection between function design and real-world use.
What to look forProvide students with a short Python code snippet containing repeated lines of code. Ask them to write a function that encapsulates the repeated logic and then rewrite the snippet using their new function. They should also identify one variable that would have local scope within their function.