Module
Module
Example
The from math import sqrt
from...import
Statement print(sqrt(8))
A module can also contain
Variables in variables like arrays,
Module dictionaries, objects etc.
Example.
"as" keyword can be
Renaming a used to rename a
Module Module.
Example
Using dir() dir() is a built-in function which lists the
identifiers defined inside a module.
function These identifiers may be functions, classes
and variables.
#module1
def new(x):
return x*3
#module2
Scope of def new(x):
Variables return x**3
import module1
import module2
ans=new(10)
Each module in Python belongs to a namespace.
This namespace includes name of all the function
and variables defined inside a module.