If you are facing any issue in playing video please use Firefox browser.
What is a Module in Python 1
In this lecture we will see that, What is module ?, What is use of it ? and How to work with user defined modules ?
A module is a file consisting of python code. A module can define functions, classes and variables. A module can also include runnable code.
For example, math module in which all the functions are provided for mathematical usage.
The python code for a module named aname normally resides in a file named 'aname.py'.
import statement in Module
You can use any Python source file as a module by executing an import statement in some other Python source file. The import has the following syntax :
import module1, module2,...moduleN
from...import statement in Module
It is also possible to import all names from a module into the current namespace by using the following import statement.
from modname import*
When you import a module the Python interpreter searches for the module in the following sequences -
We'll create a module named 'Calculatoroperations' having mathematical functions -
Now in next module if we want to use that particular module, we'll import it,
O/P – 30
from Calculatoroperations import *
Have a friend to whom you would want to share this course?