Activity 01
Pair Programming: Value vs Reference Duel
Pairs write two versions of a function: one modifying an integer by value and one by reference using addresses or objects. Call each with test data, print variables before and after, then swap and explain results. Extend to lists for visual changes.
Explain the concept of passing parameters by value versus by reference.
Facilitation TipIn Value vs Reference Duel, insist each pair prints both the memory address and the value before and after the call to make the abstraction concrete.
What to look forPresent students with two simple Python code snippets. Snippet A uses pass by value, Snippet B uses pass by reference. Ask students to predict the output of each snippet after a variable is modified within a function and explain the difference in their predictions.