QuestenaÜben und erkennen, was als Nächstes dran ist
Frage 109

A function definition uses a list as a parameter default. When is that list created, and what happens when later calls omit the argument?

  1. It is created at def time and reused.Richtige Antwort
  2. A new copy is made before every call.
  3. It is created only after the first return.
  4. A new object is created for each omission.

Erklärung

The list is created as the def statement executes, and omitted arguments bind to that same object on later calls. Assuming a fresh list or an automatic copy for every call hides the sharing that makes mutable defaults risky.

Mit diesem Test weitermachen

Übung starten
Frage 109: A function definition uses a list as a parameter default.… · Python Fundamentals · Questena