What are modules and packages?
Model answer
A module is a single .py file you can import. A package is a folder of modules (usually with an __init__.py) that groups related code. Import with import math or from math import sqrt.
Learn this topic
Modules, pip and Virtual Environments in Python in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.
More questions
- What is pip and what is requirements.txt?
- What is a virtual environment and why use it?
- What does if __name__ == "__main__" do?
- What is the difference between import styles and circular imports?
- How do you structure a medium-sized Python project?
- How do you manage and pin dependencies for reproducible builds?