Which of the following statements is true regarding list mutation and rebinding in Python?
D
Step-by-Step Solution
Key idea: This is a statement truth question testing the boundary between mutation and rebinding.
Step 1: Analyze Option A
x = x + [4] uses the + operator, which creates a new list and rebinds x. It does not mutate. (False)
Step 2: Analyze Option B
x += [4] uses augmented assignment. For lists, this mutates the existing list in place. It does not create a new list. (False)
Step 3: Analyze Option C
y = x creates an alias, not a copy. Both point to the same object. (False)
Step 4: Analyze Option D
x.append(4) is a mutating method. It changes the existing list, so any other variable pointing to the same list (aliases) will see the change. (True)
Answer: Option D