This Global vs Local Variables Test helps you to Boost your Knowledge in Python Language. In this test, we will cover the topics in the form of questions like
- The function globals() returns a dictionary of the module namespace, whereas the function locals() returns a dictionary of the current namespace.
- The global variable is shadowed, if a local variable exists with the same name as the local variable that you want to access.
- On assigning a value to a variable inside a function, it automatically becomes a local variable.
- globals() and locals() are said to be return value of the data structure dictionary