Trace tuple unpacking
The program in Listing 1 processes three pairs of integers. In each iteration, unpacking assigns the pair’s first value to first and its second value to second. The program adds first to a running total and calculates the current pair’s difference.
Complete Table 1 at the marked checkpoint after each iteration. The first row shows how to record the values. State the final printed output and explain whether unpacking changes the tuples in pairs.
| Iteration | Current pair | first |
second |
running_total |
difference |
|---|---|---|---|---|---|
| 1 | (2, 5) |
2 | 5 | 2 | -3 |
| 2 | (4, 1) |
||||
| 3 | (0, 3) |