A file containing a group of functions, Classes, and Variables which you wanted to include in your applications is called as a Module.
You can also include codes whichever you want and File must be saved with.py extension And Every Python file acts as a Module.
The advantage of python Module is that, once we define any function in a Module and save that Module with the extension .py and you can use this function in any other source file by using the Import statement.
Let us consider an example:
A file which contains the Addition functionality and product functionality and saved as demo1.py which is nothing but Module.
And I am creating another one module called demo2.py, here I am using the Addition and Product function but instead of defining the function here, I am going to import the same function from the demo1.py Module by using the import keyword.
Module demo.py a=89 b=29 def add(a,b): print("Performing the addition Operation") print("The sum:",a+b) def product(a,b): print("Performing the multiplication Operation") print("The product:", a*b)
There are several inbuilt Modules are available inside the Python, we can use these Modules in our applications easily by importing the respective Functions.
ex: Math Module, Random Module, time Module, and threading Module, etc..
Let us see what are the various functions available in the Math Module
import math print(dir(math))