Python: Which statement about LEGB Scope and Closures is the strongest interview answer?

Difficulty:

Easy

Questions:

1

Time Limit:

2 minutes

Passing Score:

100%

Question

Which statement about LEGB Scope and Closures is the strongest interview answer?

  1. LEGB Scope and Closures is mostly a naming style choice and has little effect on runtime behavior or design tradeoffs.
  2. LEGB Scope and Closures exists mainly to reduce the number of files in a Python project.
  3. LEGB Scope and Closures matters only for frontend scripting and not for backend or automation code.
  4. Python resolves names through local, enclosing, global, and built-in scopes, which is commonly summarized as LEGB.

Hint

Start with the core rule behind LEGB Scope and Closures.

Answer and rationale

Correct answer: D. Python resolves names through local, enclosing, global, and built-in scopes, which is commonly summarized as LEGB.

Python resolves names through local, enclosing, global, and built-in scopes, which is commonly summarized as LEGB. This is the base concept interviewers commonly test first.

Track: Python