Recall & Review
beginner
What is a Python package?
A Python package is a folder that contains a special file called
__init__.py and other Python files or subfolders. It helps organize code into groups so it is easier to find and use.Click to reveal answer
beginner
What is the purpose of the
__init__.py file in a package?The
__init__.py file tells Python that the folder should be treated as a package. It can be empty or contain code that runs when the package is imported.Click to reveal answer
beginner
How do you import a module from a package?Use the dot notation: <code>import package_name.module_name</code> or <code>from package_name import module_name</code>. This lets you use the code inside that module.Click to reveal answer
intermediate
What is a subpackage in Python?
A subpackage is a package inside another package. It is a folder with its own
__init__.py file inside the main package folder.Click to reveal answer
beginner
Why is organizing code into packages helpful?
It keeps code neat and easy to find, helps avoid name conflicts, and makes it easier to share and reuse code in different projects.
Click to reveal answer
What file must be present in a folder for Python to recognize it as a package?
✗ Incorrect
The
__init__.py file marks a folder as a Python package.How do you import the module
tools from the package utils?✗ Incorrect
Use
import utils.tools to import the tools module inside the utils package.What is a subpackage?
✗ Incorrect
A subpackage is a package folder inside another package folder.
Which statement is true about
__init__.py?✗ Incorrect
__init__.py can be empty or contain initialization code for the package.Why use packages in Python?
✗ Incorrect
Packages help organize code and prevent name conflicts by grouping related modules.
Explain what a Python package is and how it is structured.
Think about folders and special files that group code.
You got /3 concepts.
Describe how to import a module from a package and why this is useful.
Consider how you tell Python where to find the code you want.
You got /4 concepts.