Python Libraries
Python Libraries
|he>M'odole ’Module :
Pthonibraries Modules
a) 2) A When
together
Apython varables,dloases
Package statements module is
funcHons, Aaode Pyfhon
1) m-needs
klas is easler Thlcontain
s A Notes - clasfellov
Functions library commonly
module
extenslon cLpproach, we
i to
program functions
packaae blw pe understand, break is
Apythan A Sub-rmodules. / US
of module or ed simply
Module which
is pactage this package
comprisea that a Using
ibrary. m
pr
a s odule
Hle js oqramnto
ismodules, a Chapter’4
collecion a Phckage test pexform
directory a called file Py
is 3main that
ftle thon
&
py that
contalning & Contain
modularlsation,
maintain related
of(or
lbrary ibrarles
relabed
tolder) component6 contalns
i= GOUrce tasks.
chould
module
each
ofeython pethon py
modulea
i code thon 1CPPL
Date:
2094
PageNo. 16lo41
make
dellnition,
that for code.
the
modules.. generic
works proqrarm
Page No.
dlassfalov
python.
Library many package in
collecton of Library & packaga.
Library Is a diference blw
no
Cnenerally there is
Script Vs Module -
> Pthon
Scrigt
python fle that intends to be e ruh directly.
Hscript s a should do &omething.
run it,t
Nhen you
Module
python file that iad Intends to be imporked
A madale is a
into scrlps or othex mod ules.
clases , funcion & Varlables intendet
9t often defines mermbes ike
to be USed n otber Ale that import it
Sonpk Module
def add (a, b): def add la, b) :
return a+ return(o+b)
yesult = add ( 6,)
printGresult)
Random Modulei
Used when we requlre SUch no. that are not known earlier.
ex- Captcha or any serial numn bersthen, in tbis situaton we
need O random no.
Pseudarandom no. or Lottery teca ptcha Cike in Lagln fom
a
random no. genera tor to qen evate which image is to
be kn Dbh to the USer.
plcktng a con.
Jo Use randomi fun Mon wehave to imgort random module,
’
*
Swffle)
* method *
method:
exi- stcing Cholce) 94
Randomn
Random clasfellow
Sule This This RandintO
Uniform) wbich
RandrangeDfunchan
inteqer
Returns method
dom.Choice(sseqvence >) doe
method or
listist First not
Functon:-
a bl mod
rondorm any fin
X require ule
in can no.
isnvmbers.
retorns3t given in
other
replace sufle y5ed Is
elernent qenerate Python:
This
lower This
lower& or an 1
seqyencee
the selectlon
randomfor method brt
& any limitmethod arqument.
fram excludingo)
return tems upper
floating
paint i-
o the &take This
None second limit yalue
the qlven
glven 2para metbod
blo
seqvence. from no. Retorn
no is &1o Date:
PageNo. 1CPPL
list always
list, metera,b)
blo b/ Ploat I20)
tuple no.
returna (Hnetucling
extluding
gien b/sO
or
in
an &
1
code,
I120
followlng e)
Page
No. NaNUMBER]+ ") = )
Data
:
the =
end end end
from C*5))
(20+random.rondomC*5)
O*5),
rondom.random5)
exected
minmum [N]+STR)
3) randam-random
Yandom-randoo
(O, !=:
6TRINGCN]
while t1
outcomes randomrandintNUMBER cade:
&, NE
NLI
imum (sIRIN folloing
posslble O
max BSE =
NUMBER ISt
Yandom+ + (20+
import
20 (20 25 24
29 24
223
24 21
"C print N-1.
N L0#
classfallow Progzama the NUM8ER= IO ON the (int intl
LE#
NO#
Qre = NB# (IntCint 24 21
STRING # IE#
specify NE Conaldey printprintprlntprint 22 22
23 21
-what ES# t#
NS#EC 20
23
2
C) a.) b)
b) c)