PRACTICE • LEARN • GROW
Module 11: Modules and Packages - Final Quiz MCQs
Solve topic-wise placement questions and improve your skills.
Module 11: Modules and Packages - Final Quiz Progress
0 of 11 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
In Python, what is the file requirement for creating an importable module?
A.
It must be compiled into a binary .dll or .so file
B.
Any plain text file ending with the .py extension is automatically an importable module
C.
It must inherit from the Module class
D.
It must be placed in the C:\Python directory
Explanation & Key
Correct Answer:
2
What is the purpose of the
__init__.py file inside a package directory?
A.
It compiles all modules in the directory ahead of time
B.
It signals to the Python interpreter that the directory should be treated as an importable package and initializes package-level state
C.
It deletes duplicate files automatically
D.
It acts as a configuration file for pip
Explanation & Key
Correct Answer:
3
What is the value of the special built-in variable
__name__ when a script is executed directly from the terminal (e.g. python script.py)?
A.
'__main__'
B.
'script'
C.
'__init__'
D.
None
Explanation & Key
Correct Answer:
4
Why is the wildcard import
from module import * widely considered a bad practice in production code?
A.
It causes syntax errors in Python 3
B.
It pollutes the local namespace with unknown names and risks silently shadowing existing variables or functions
C.
It disables the garbage collector
D.
It cannot import functions
Explanation & Key
Correct Answer:
5
Which Python standard library list contains the directories searched by the interpreter when an
import statement is executed?
A.
os.path
B.
sys.path
C.
sys.modules
D.
pip.search_path
Explanation & Key
Correct Answer:
6
What is the official third-party software repository for Python packages installed via
pip?
A.
GitHub
B.
Python Package Index (PyPI)
C.
npm registry
D.
SourceForge
Explanation & Key
Correct Answer:
7
What is the primary architectural purpose of using Python Virtual Environments (
venv)?
A.
To simulate different computer operating systems
B.
To isolate package dependencies and versions per project, preventing conflicts between incompatible package versions
C.
To run Python code in the browser
D.
To encrypt source code before distribution
Explanation & Key
Correct Answer:
8
Which command creates a new virtual environment named
myenv using Python's built-in module?
A.
pip install venv myenv
B.
python -m venv myenv
C.
create-venv myenv
D.
python --new-env myenv
Explanation & Key
Correct Answer:
9
How do you generate a standard list of all currently installed packages and their exact versions into a file?
A.
pip list > packages.json
B.
pip freeze > requirements.txt
C.
python -m pip export
D.
pip save requirements
Explanation & Key
Correct Answer:
10
What is an alias import in Python?
A.
import math as m
B.
from math import *
C.
rename math to m
D.
alias math = m
Explanation & Key
Correct Answer:
11
What error occurs when Module A imports Module B, and Module B simultaneously imports Module A at top level?
A.
RecursionError
B.
Circular Import (ImportError / AttributeError due to partially initialized modules)
C.
SegmentationFault
D.
DeadlockError
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong