This Python Namespace Quiz tests your understanding of how Python manages identifiers using different scopes like local, global, enclosing, and built-in. Strengthen your core knowledge of Python variable handling and memory referencing.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Which of the following is not a type of Python namespace?
Correct
Incorrect
Question 3 of 15
3. Question
What is the order of namespace resolution in Python (LEGB Rule)?
Correct
Incorrect
Question 4 of 15
4. Question
Where are built-in functions like len() or print() stored?
Correct
Incorrect
Question 5 of 15
5. Question
What will be the output of this code?
x = 10 def test(): x = 20 print(x)
test() print(x)
Correct
Incorrect
Question 6 of 15
6. Question
What happens if a variable is not found in the local namespace?
Correct
Incorrect
Question 7 of 15
7. Question
What will be the output of the following code?
def outer(): x = “outer” def inner(): print(x) inner()
outer()
Correct
Incorrect
Question 8 of 15
8. Question
What keyword is used to modify a global variable inside a function?
Correct
Incorrect
Question 9 of 15
9. Question
What will be the output?
def test(): global x x = 50
test() print(x)
Correct
Incorrect
Question 10 of 15
10. Question
Which namespace is created when a function is called?
Correct
Incorrect
Question 11 of 15
11. Question
What will be the output of this code?
x = “global” def outer(): x = “enclosing” def inner(): print(x) inner()
outer()
Correct
Incorrect
Question 12 of 15
12. Question
Which namespace exists as long as the program runs?
Correct
Incorrect
Question 13 of 15
13. Question
What is the scope of a variable defined inside a function without global keyword?
Correct
Incorrect
Question 14 of 15
14. Question
How can you list all the names defined in the current namespace?
Correct
Incorrect
Question 15 of 15
15. Question
What function can you use to access the global namespace as a dictionary?
Correct
Incorrect
Summary
These MCQs on Python Namespace cover variable resolution, LEGB rule, local/global scopes, and how Python looks up variable names. This quiz is essential for interview prep and deep understanding of how Python memory and execution models work.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.