A programmer usually prefer the predefined functions and variables for document,
Modules are collection of several diffrent definitions(functions and variables)
and statements.Or to put simply The files with ".py" appended at the name of the
source code,the user can import that module(files) or specific function fromthat
module into the file.
programmer use the module,complete project in less time and more efficient way.
programmer generally import either the module which user saved with ".py" or can
use some standard module like random,queue,array,math,profile,statistics etc....
just type "help('modules')" and you can see all standard modules in interactive
mode.
-------------------------------------------------------------------------------
Eg-->
>>> import math
>>> math.cos(60)
-0.9524129804151563
>>> math.ceil(6.12)
7
>>> math.log2(4)
2.0
-------------------------------------------------------------------------------
Eg-->
>>> from math import sqrt,sin
>>> sqrt(9)
3.0
>>> sin(60)
-0.3048106211022167
>>> cos(60)
'''Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
cos(60)
NameError: name 'cos' is not defined'''
>>> math.cos(60)
'''Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
math.cos(60)
NameError: name 'math' is not defined'''
-------------------------------------------------------------------------------