QuestenaՎարժանք, որը ցույց է տալիս՝ ինչ կրկնել հաջորդիվ
Հարց 34

A program runs `a = [[1]]`, `b = a.copy()`, and `b[0].append(2)`. What is `a`?

  1. `[[1, 2]]`Ճիշտ պատասխան
  2. `[[1]]` because every nested object was copied
  3. `[1, 2]` because the outer level is removed
  4. `None` because copy mutates its receiver

Բացատրություն

The copy has a distinct outer list but retains a reference to the same nested list as `a`. Mutating that inner object is visible through both outer lists, while a recursive copy would have prevented the shared change.

Շարունակեք այս թեստով

Սկսել վարժանքը
Հարց 34: A program runs `a = [[1]]`, `b = a.copy()`, and… · Python Fundamentals · Questena