Python: Which statement about Mutable Default Arguments is the strongest interview answer?

Difficulty:

Easy

Questions:

1

Time Limit:

2 minutes

Passing Score:

100%

Question

Which statement about Mutable Default Arguments is the strongest interview answer?

  1. Mutable Default Arguments is mostly a naming style choice and has little effect on runtime behavior or design tradeoffs.
  2. Default argument values are evaluated once when the function is defined, not every time the function is called.
  3. Mutable Default Arguments exists mainly to reduce the number of files in a Python project.
  4. Mutable Default Arguments matters only for frontend scripting and not for backend or automation code.

Hint

Start with the core rule behind Mutable Default Arguments.

Answer and rationale

Correct answer: B. Default argument values are evaluated once when the function is defined, not every time the function is called.

Default argument values are evaluated once when the function is defined, not every time the function is called. This is the base concept interviewers commonly test first.

Track: Python