Questenaتمرینی که نشان می‌دهد بعد چه چیزی را مرور کنید
سؤال 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.پاسخ درست
  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.

توضیح

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.

ادامهٔ این آزمون

شروع تمرین
سؤال 109: A function definition uses a list as a parameter default.… · Python Fundamentals · Questena