Question 1
Topic: Computer Programming Fundamentals
Skill tested: Evaluates Python assignment, object identity, and mutable list aliasing.
A reporting script initializes `primary = [4, 7]` and then assigns `backup = primary`. A later operation executes `backup += [9]`, after which the script prints both variables. The developer expected `backup` to contain the added value while leaving `primary` unchanged, because the operation looks like a reassignment. The script must retain the original list independently for a later comparison, and the developer wants the smallest code change that makes the intended behavior reliable. Which change should be made before modifying `backup`?
The initial assignment makes both names refer to the same mutable list. Augmented assignment with a list extends that list in place, so both names observe the change. A shallow copy using `primary.copy()` creates an independent list, which is sufficient here because the elements are integers. Replacing `+=` with `+` would create a new list at that later step, but the original shared reference already exists and the code's intended independence is clearer and reliable when the copy is made. Tuples cannot be extended in place, and comments do not change runtime behavior.