MENU
Question -

Explain the term ‘Module’.



Answer -

Module : A module is a file containing Python definitions and statements. Standard library of Python is extended as modules to a programmer. Definitions from the module can be used within the code of a program. To use these modules in the program, a programmer needs to import the module. There are many ways to import a module in program :
(i) Import
(ii) from
(i) Import: It is simplest and most common way to use modules in our code. Its syntax is :
> > > import module name 1 [, module name 2,………. ]
Example,
> > > import math
> > > value = math.sqrt (25)
(ii) From : It is used to get a specific function in the code instead of the complete module file.
If we know before hand which functions, we will be needing, then we may use ‘from’. For modulus having large number of functions, it is recommended to use ‘from’ instead of import. Its syntax is
> > > from module name import function name 1 [, function name 2, ……….]
Example,
> > > from math import sqrt
> > > value = math . sqrt (36)

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×