What is the order of namespaces in which Python looks for an identifier?
A. Python first searches the built-in namespace, then the global namespace and finally the local namespace
B. Python first searches the built-in namespace, then the local namespace and finally the global namespace
C. Python first searches the local namespace, then the global namespace and finally the built-in namespace
D. Python first searches the global namespace, then the local namespace and finally the built-in namespace
Answer: Option B
Solution (By Examveda Team)
When Python encounters an identifier (variable or function name), it searches for it in a specific order across different namespaces.The order of namespaces that Python looks for an identifier is:
Built-in namespace: Python first searches the built-in namespace, which contains the names of all built-in functions, exceptions, and constants.
Local namespace: Next, Python searches the local namespace, which contains names defined within the current function or code block.
Global namespace: If the identifier is not found in the local namespace, Python searches the global namespace, which contains names defined at the top level of the current module or in the global scope.
If the identifier is not found in any of these namespaces, Python raises a NameError.
Therefore, the correct order of namespaces in which Python looks for an identifier is: built-in namespace, local namespace, global namespace.
What is Python primarily used for?
A. Web browsing
B. Data analysis
C. Video editing
D. Game development
Who developed Python Programming Language?
A. Wick van Rossum
B. Rasmus Lerdorf
C. Guido van Rossum
D. Niene Stom
Which of the following is an advantage of Python?
A. It compiles to machine code
B. It enforces strict typing
C. It has a large standard library
D. It requires extensive memory management
What is the role of the Python interpreter?
A. To convert Python code to assembly language
B. To manage memory allocation
C. To execute Python code line by line
D. To compile Python code into bytecode

Join The Discussion