Python Scope and the LEGB Rule: Resolving Names in Your Code Quiz

Interactive Quiz ⋅ 11 Questions
By Leodanis Pozo Ramos

In this quiz, you’ll test your understanding of Python Scope and the LEGB Rule: Resolving Names in Your Code.

By working through this quiz, you’ll revisit how namespaces defines the scope of names. You’ll also apply the LEGB rule, and practice using globals() and locals() to inspect your code’s environment.

The quiz contains 11 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end of the quiz, you’ll receive a total score. The maximum score is 100%. Good luck!

Related Resources

Course

The LEGB Rule & Understanding Python Scope

In this step-by-step video course, you'll learn what scopes are, how they work, and how to use them effectively to avoid name collisions in your code.

intermediate python

Tutorial

Python Scope and the LEGB Rule: Resolving Names in Your Code

Understanding Python's variable scope and the LEGB rule helps you avoid name collisions and unexpected behavior. Learn to manage scope and write better code.

intermediate python