Modules and Packages
Everyone gets confused between all these Functions, Modules, and Packages.
Just see this Image…….We understand that Package contains a collection of modules and a module contains a collection of Functions.
Thus, we can say Functions are the subset of modules and Modules are the subset of Packages.
Modules
A module is a Python file with a .py extension that can be imported into another Python program.
The name of the Python file becomes the module name.
The module contains:
1)?definitions and implementation of classes?
2)?variables?
3)?functions?that can be used inside another program.
Advantages of modules :
To create a function —?A function is defined using the def keyword
1. Creating a Module
In this program, we have created 4 functions for adding, multiplying, subtracting, and division. Saving this file as Operations.py
2. Importing a Module
Importing the function using?the import statement and typing the name of the module