3.2 - LEGB Rule
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
What does each letter in LEGB stand for?
💡 Hint: You can think of the order Python uses to check variable names.
Provide an example of a Local variable.
💡 Hint: Remember, it's defined within a function.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What does 'G' stand for in LEGB?
💡 Hint: Think of where the variable is accessible.
True or False: The local variables are accessible from outside the function.
💡 Hint: Consider the scope of variables.
2 more questions available
Challenge Problems
Push your limits with advanced challenges
Create a function that defines a local variable and attempts to print it from outside the function.
💡 Hint: Consider where you are trying to access the variable.
Write a code segment that uses the 'nonlocal' keyword to modify a variable in an enclosing scope.
💡 Hint: Think about how nested functions interact with variable scope.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.