Question
Which statement about LEGB Scope and Closures is the strongest interview answer?
- LEGB Scope and Closures is mostly a naming style choice and has little effect on runtime behavior or design tradeoffs.
- LEGB Scope and Closures exists mainly to reduce the number of files in a Python project.
- LEGB Scope and Closures matters only for frontend scripting and not for backend or automation code.
- 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