Which one is not correct ?
print(__name__)
Attribute __name__ is created by default. But you can still assign a value to it
print(__name__) __name__ = 'my module' print(__name__)
Output :
Which of the following is not correct about main modules?
Special name given to main modules is: __main__
Other main modules or scripts can import main modules
Main modules may import any number of other modules
When a python file (.py) is directly executed, it is considered main module of a program
Main modules are not meant to be imported into other modules or scripts that are directly run
Which of the statements about modules is false?
When a module is loaded, a compiled version of the module with file extension .pyc is automatically produced in __pycache__
dir() built-in function provides the items in the namespace of the main module.
In the from ..... import form of import, identifiers beginning with two underscores are private and aren’t imported
In the from .. import form of import, all identifiers regardless of whether they are private or public are imported.
In the from .. import form of import, the private identifiers beginning with two underscores are not imported
What is the order of namespaces in which Python interpreter looks for an identifier?
The built-in namespace - > the local namespace - > the global namespace
the global namespace -> the built-in namespace - > the local namespace
the built-in namespace - > the global namespace -> the local namespace
the local namespace -> the global namespace -> the built-in namespace
Python first searches the local namespace, then the global namespace and finally the built-in namespace.