Test Series - python

Test Number 77/108

Q: Which of these definitions correctly describes a module?
A. Denoted by triple quotes for providing the specification of certain program elements
B. Design and implementation of specific functionality to be incorporated into a program
C. Defines the specification of how it is to be used
D. Any program that reuses code
Solution: The term “module” refers to the implementation of specific functionality to be incorporated into a program.
Q: Which of the following is not an advantage of using modules?
A. Provides a means of reuse of program code
B. Provides a means of dividing up tasks
C. Provides a means of reducing the size of the program
D. Provides a means of testing individual parts of the program
Solution: The total size of the program remains the same regardless of whether modules are used or not. Modules simply divide the program.
Q: Program code making use of a given module is called a ______ of the module.
A. Client
B. Docstring
C. Interface
D. Modularity
Solution: Program code making use of a given module is called the client of the module. There may be multiple clients for a module.
Q: ______ is a string literal denoted by triple quotes for providing the specifications of certain program elements.
A. Interface
B. Modularity
C. Client
D. Docstring
Solution: Docstring used for providing the specifications of program elements.
Q: Which of the following is true about top-down design process?
A. The details of a program design are addressed before the overall design
B. Only the details of the program are addressed
C. The overall design of the program is addressed before the details
D. Only the design of the program is addressed
Solution: Top-down design is an approach for deriving a modular design in which the overall design.
Q: In top-down design every module is broken into same number of submodules.
A. True
B. False
C. none
D. ..
Solution: In top-down design every module can even be broken down into different number of submodules.
Q: What will be the output of the following Python code?

#mod1
def change(a):
    b=[x*2 for x in a]
    print(b)
#mod2
def change(a):
    b=[x*x for x in a]
    print(b)
from mod1 import change
from mod2 import change
#main
s=[1,2,3]
change(s)
A. [2,4,6]
B. [1,4,9]
C. [2,4,6] [1,4,9]
D. There is a name clash
Solution: A name clash is when two different entities with the same identifier become part of the same scope. Since both the modules have the same function name, there is a name clash.
Q: Which of the following isn’t true about main modules?
A. When a python file is directly executed, it is considered main module of a program
B. Main modules may import any number of modules
C. Special name given to main modules is: __main__
D. Other main modules can import main modules
Solution: Main modules are not meant to be imported into other modules.
Q: Which of the following is not a valid namespace?
A. Global namespace
B. Public namespace
C. Built-in namespace
D. Local namespace
Solution: During a Python program execution, there are as many as three namespaces – built-in namespace, global namespace and local namespace.
Q: Which of the following is false about “import modulename” form of import?
A. The namespace of imported module becomes part of importing module
B. This form of import prevents name clash
C. The namespace of imported module becomes available to importing module
D. The identifiers in module are accessed as: modulename.identifier
Solution: In the “import modulename” form of import, the namespace of imported module becomes available to, but not part of, the importing module.

You Have Score    /10