Explore topic-wise MCQs in Python.

This section includes 20 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.

1.

What is the order of namespaces in which Python looks for an identifier?

A. Python first searches the global namespace, then the local namespace and finally the built-in namespace
B. Python first searches the local namespace, then the global namespace and finally the built-in namespace
C. Python first searches the built-in namespace, then the global namespace and finally the local namespace
D. Python first searches the built-in namespace, then the local namespace and finally the global namespace
Answer» C. Python first searches the built-in namespace, then the global namespace and finally the local namespace
2.

Which of the statements about modules is false?

A. In the “from-import” form of import, identifiers beginning with two underscores are private and aren’t imported
B. dir() built-in function monitors the items in the namespace of the main module
C. In the “from-import” form of import, all identifiers regardless of whether they are private or public are imported
D. When a module is loaded, a compiled version of the module with file extension .pyc is automatically produced
Answer» D. When a module is loaded, a compiled version of the module with file extension .pyc is automatically produced
3.

Which of the following is false about “from-import” form of import?

A. The syntax is: from modulename import identifier
B. This form of import prevents name clash
C. The namespace of imported module becomes part of importing module
D. The identifiers in module are accessed directly as: identifier
Answer» C. The namespace of imported module becomes part of importing module
4.

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
Answer» B. This form of import prevents name clash
5.

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
Answer» E.
6.

All modular designs are because of a top-down design process.

A. True
B. False
Answer» C.
7.

In top-down design every module is broken into same number of submodules.

A. True
B. False
Answer» C.
8.

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
Answer» D. Only the design of the program is addressed
9.

Program code making use of a given module is called a ______ of the module.

A. Client
B. Docstring
C. Interface
D. Modularity
Answer» B. Docstring
10.

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
Answer» C. Special name given to main modules is: __main__
11.

MODULES_THAT_HAVE_MORE_THAN_ONE_ITEM_IN_THEIR_API_CAN_________?$

A. Assign itself to a global variable
B. Invoke another module of the same kind
C. Return a namespace object
D. Invoke another module of the same kind
Answer» C. Return a namespace object
12.

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
Answer» C. The namespace of imported module becomes available to importing module
13.

Which of the following is not a valid namespace?$

A. Global namespace
B. Public namespace
C. Built-in namespace
D. Local namespace
Answer» B. Public namespace
14.

The provides() function and the exportsobject are used to _________$

A. Register the module’s API and Store their API
B. Call the modules api
C. Store the module’s API
D. Register the modules api
Answer» D. Register the modules api
15.

Which of the following is false about “from-import” form of import?$

A. The syntax is: from modulename import identifier
B. This form of import prevents name clash
C. The namespace of imported module becomes part of importing module
D. The identifiers in module are accessed directly as: identifier
Answer» D. The identifiers in module are accessed directly as: identifier
16.

The scope of a function is also called as _______?

A. Predefined function
B. Module function
C. Public function
D. Private function
Answer» E.
17.

All modular designs are because of a top-down design process? True or False?

A. True
B. False
Answer» C.
18.

In top-down design every module is broken into same number of submodules? True or False?

A. True
B. False
Answer» C.
19.

______ is a string literal denoted by triple quotes for providing the specifications of certain program elements.

A. Interface
B. Modularity
C. Client
D. Docstring
Answer» E.
20.

The maximum number of global symbols a module can define is ____________

A. 2
B. 3
C. 1
D. 4
Answer» D. 4