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

A program runs `data = dict(a=1, b=2)` and then assigns 3 to the existing key `a`. What does `list(data.items())` return?

  1. `[("a", 1), ("b", 2), ("a", 3)]`
  2. `[("a", 1), ("b", 2)]`
  3. `[("b", 2), ("a", 3)]`
  4. `[("a", 3), ("b", 2)]`Ճիշտ պատասխան

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

Updating an existing key replaces its mapped value while retaining that key's original insertion position. Moving `a` after `b` would incorrectly treat an update as deletion followed by fresh insertion.

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

Սկսել վարժանքը
Հարց 44: A program runs `data = dict(a=1, b=2)` and then assigns 3… · Python Fundamentals · Questena