Computer Science
Assertion. After importing a module through import statement, all its function definitions, variables, constants etc. are made available in the program.
Reason. Imported module's definitions do not become part of the program's namespace if imported through an import <module> statement.
Python Libraries
1 Like
Answer
(b)
Both Assertion and Reason are true but Reason is not the correct explanation of Assertion.
Explanation
The import <module>
statement imports the entire module, making its contents available in a new namespace with the same name as the module. They do become accessible in the program's namespace through dot notation, but they are not added directly to the current namespace.
Answered By
2 Likes
Related Questions
The statement from <module> import <objects> is used to import a module in full.
Assertion. The documentation for a Python module should be written in triple-quoted strings.
Reason. The docstrings are triple-quoted strings in Python that are displayed as documentation when help <module> command is issued.
Assertion. If an item is imported through from <module> import <item> statement then you do not use the module name along with the imported item.
Reason. The from <module> import command modifies the namespace of the program and adds the imported item to it.
Assertion. Python's built-in functions, which are part of the standard Python library, can directly be used without specifying their module name.
Reason. Python's standard library's built-in functions are made available by default in the namespace of a program.