using python libraries class 12 solution
chapter – 3
What is python library modules
a module is a file containing python definitions,functions,variables,classes and statement.the extension of this file is “.py”.
what is python package:-
is directory (folder) of python module.
library:- is a collection of many packages in python. generally there is not difference between python package and python library.
1. we can import to functionally in any program and use it.
2. re usability is one of the biggest advantage.
3.same attribute can be stored in one module.
Q 1. how to make module in python.
1. create .py file and define function and give an appropriate name ex. shape.py.
1. def area circle(r):
2. def area rectangle(a,b):
3. def area cylender(r):
2. import the file in main driver code
print(shape.area of cylender(10,7))
name space in python
types of name space
1. name space is used to separate different section of program.
2. to define the name space it is necessary to define the terms.
python has three types of name space.
1. global (within the entire file)
2. local (within the function)
3. built-in (entire python libraries)
python use LEGB rule to find whether a variable or function is available for process of sequence of searching the variable or is as below.
L – first variable checked in local environment.
E – then variable checked in enclosing environment.
G – then variable checked in global environment.
B – then variable checked in built-in environment.
other wise python will generate as error.
standard python libraries
these libraries is readily available in python compiler for example-math, datetime, mathplotlib etc.
import datetime as dt