gs gs109 Python Modules - Python Modules - Quiz No.2
gs gs109 Python Quiz
This quiz belongs to book/course code gs gs109 Python of gs organization. We have 134 quizzes available related to the book/course Python. This quiz has a total of 5 multiple choice questions (MCQs) to prepare and belongs to topic Python Modules. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: Which of the following is false about “import modulename” form of import?
The namespace of imported module becomes part of importing module
This form of import prevents name clash
The namespace of imported module becomes available to importing module
The identifiers in module are accessed as: modulename.identifier
Question 2: Which of the following is false about “from-import” form of import?
The syntax is: from modulename import identifier
This form of import prevents name clash
The namespace of imported module becomes part of importing module
The identifiers in module are accessed directly as: identifier
Question 3: Which of the statements about modules is false?
In the “from-import” form of import, identifiers beginning with two underscores are private and aren’t imported
dir() built-in function monitors the items in the namespace of the main module
In the “from-import” form of import, all identifiers regardless of whether they are private or public are imported
When a module is loaded, a compiled version of the module with file extension .pyc is automatically produced
Question 4: What will be the output of the following Python code?
from math import factorial print(math.factorial(5))
120
Nothing is printed
Error, method factorial doesn’t exist in math module
Error, the statement should be: print(factorial(5))
Question 5: What is the order of namespaces in which Python looks for an identifier?
Python first searches the global namespace, then the local namespace and finally the built-in namespace
Python first searches the local namespace, then the global namespace and finally the built-in namespace
Python first searches the built-in namespace, then the global namespace and finally the local namespace
Python first searches the built-in namespace, then the local namespace and finally the global namespace