🧩Module (Programming)
Also known as Module, Code Module, Software Module
A file of code. Other files can import it and use its parts.
Think of it like
It is like a kitchen drawer. Spoons go in one, and pans go in another.
Example
Jack's shop app has a module named prices.py. The cart code imports it to work out each total.
Why it matters
With modules, many people can work on one codebase at once. A bug is easier to find in a small file.
Definition
Example code
python
# prices.py
def add_tax(amount):
return amount * 1.2
# cart.py
from prices import add_tax
print(add_tax(10)) # 12.0Common mistake
Key takeaways
- 1Group related code. One job or topic per module.
- 2Import to use. Other files pull in what they need.
- 3Small parts. Easier to read, test and change.