Modules are code files meant to be used by other programs. In order to use a module, we use the import
statement. A module can import other modules.
Let's discuss the simple Python program:
def sum1(a,b): c = a+b return c def mul1(a,b): c = a*b return c
The preceding code is a very easy and basic example. Let's save the program as module1.py
. You can consider that the preceding program is the Python module. We will use module1.py
. Consider, while making another program, you need multiplication or addition of two numbers. You need not make any function. You can take the advantage of module1.py
.