You are on page 1of 86

Maharashtra State

Board of Technical Education


Certificate
This is to certify that Mr. / Ms. Tejashree Satish Shinde.
Roll No 61 of Sixth Semester of Diploma in
COMPUTER ENGINEERING of Institute
VIDYA PRASARAK MANDAL’S POLYTECHNIC, THANE.
(Code 0007) has completed the term work satisfactorily in subject
Programming with Python (22616) for the academic year 2020 to
2021 as prescribed in the curriculum.

Place Thane Enrollment No. 1800070132


Date: 20/06/2021 Exam Seat No. 103813

Subject Teacher Head of the Department Principal

Seal of
the
Institute
Content Page
List of Practical’s and Progressive Assessment Sheet.

Dated
Sr Page Date of Data of Assessment Remark
Title of the Practical sign of
No No. performance Submission marks (50) (if any)
teacher
Install and configure Python
1 IDE 1 8/4/21 22/4/21 50
Write simple python program
2 to display message on screen 10 8/4/21 22/4/21 50
Write simple Python program
using operators:
3 a) Arithmetic Operators. 15 8/4/21 22/4/21 50
b) Logical Operators
c) Bitwise Opeartors..
Write simple Python program
to demonstrate use of
conditional statements:
4 21 14/4/21 23/4/21 50
a) ‘if’ statement
b) ‘if … else’ statement
c) Nested ‘if’ statement
Write Python program to
demonstrate use of looping
statements:
5 27 14/4/21 10/05/21 50
a) ‘while’ loop
b) ‘for’ loop
c) Nested loops
Write Python program to
perform following operations
on Lists:
a) Create list
6 35 14/4/21 20/05/21 50
b) Access list
c) Update list (Add item,
Remove item)
d) Delete list
Write Python program to
perform following operations
on Tuples:
7 a) Create Tuple 41 14/4/21 20/05/21 50
b) Access Tuple
c) Update Tuple
d) Delete Tuple
Write Python program to
perform following operations
on Tuples:
a) Create Set
8 48 24/4/21 08/06/21 50
b) Access Set elements
c) Update Set
d) Delete Set
e)
Write Python program to
perform following operations
on Dictionaries:
a) Create Dictionary
b) Access
9 54 24/4/21 09/06/21 50
Dictionaryelements
c) Update Dictionary
d) Delete Set
e) Looping through
Dictionary
a) Write Python program to
demonstrate math built- in
functions (Any 2 programs) b)
10 61 17/5/21 09/06/21 50
Write Python program to
demonstrate string built – in
functions (Any 2 programs)
Develop user defined Python
function for given problem:
a) Function with
11 67 17/5/21 09/06/21 50
minimum 2 arguments
b) Function returning
values
Write Python program to
demonstrate use of:
a) Builtin module (e.g.
12 73 17/5/21 10/06/21 50
keyword, math,
number, operator)
b) user defined module.
Write Python program to
demonstrate use of:
13 a) built-in packages (e.g. 80 17/5/21 10/06/21 50
NumPy, Pandas)
b) user defined packages
Write a program in Python to
demonstrate following
14 operations: 86 17/5/21 10/06/21 50
a) Method overloading
b) Method overriding
Write a program in Python to
demonstrate following
15 operations: 92 17/5/21 10/06/21 50
a) Simple inheritance
b) Multiple inheritance
Write a program in Python to
16 handle user defined exception 98 17/5/21 10/06/21 50
for given problem
Total Marks 800
Total Marks (Scaled to 25 Marks) (50)25
Page No.
Date
aachical N:
Aim:Tnatall and_onhgure Pyhon TDE
TXResource used
|5aNoNome.c Repuce. spacihcei.on inyRemak
A Computer ystem Lomputeflis, A
2
868 RAM)
Cperahing yatemwindouws 10
Developme.nt Pytnan TDE
Sooae
XIPctica reloted aueahons
4nlnte steps `nx intalling non on
2arelling Pytaon in Windauds: indauls
lpen ony itenneF
mou6enupetipsANWW.
downloscalin _addres hc and tnted Pfnon.org
Home poce d ton viNNG
ick on_dounloid the Cisplayed.
gtest Neasion y windaus
-Open tne pthon 314 xerian pack and
stoT double dick on it
instolakion gnd inatollathon indouls
Clid on ext inato0oL r vill he cpen
inxtalaion ond Hhen Stup
10gsessilndoud u be aened
Haer compleke me
in Pne indaus
intallaion,Cick an close buton

25toke DLE in Ython


DLE(Tategeoted Development anc
on integtabed lecning nvizonmert
denelopment_enwronment
arich hos been oundled x puinan,
unan
ith hedekcult icmpeme.ntciun
Page No.

Date
L

3|list key eahu es o Pahon.


Feotures putnon
Losy to code.
meé cand open50UIce
- Objeck griented landuaige
-6 pr0qoming suppoit
xtensibde eoure
-Postoble 1anouaE
ntecaoted lanckIgeP
-Tatezpeked lanacde
- Dunamicedly ypec Langucie
Altxplcin pathon paBh.
PTHONPATH i environment vOiales ied tu set pih hy
the useM-deined modules s0 hok can he cdirechy
impozted into putnon procsam. is olao xAponole
x handling tne defaut secncn poth Xox punon modules

55tote uae oý p ond pep


Starda o pthon eohancement pioposo } PEP is
a design documnt oronding inoimohon o tMe
mon communiy ox deacaibing ew ectures#
n Phon or i r o c e s om envranment.

PTP is O Packce mangementsstem witten _in-


lextnon ued u idatall and managë sdktuuarepadsg
Page No.
Date

Xxecise
Painthe vesion o lyhon.
Codeimport S
roint(s5.vession )
Outpuk- 376 laeout, Jon 82620,20:23:.29) M5. v_1gi6 64ht [kA
2|\plrite steps D \oad pAnon intexpreker in
Lres stoab buthan yuindaus
2 Secach mpyinon.3.7/32 bit)
S.Cick on pathon B732 bit)
a Ython inteachve psompt in
will apped than_comonandl line

OR yDu Can cdlsa use puthan IDI:


1Less stadt buuttin
2 (lick an TDLE (PUtnan 3.7 32bit)
3. PuthoY intesiachve Paampt_lL
Oppear
I |Campekency and Hackicc Akills
Dewelop genesalAuaposeprogrmnq uáng atndn u sulue_prodlem
Ihe practica is apecked b develap the laing skills
-5decngand gtcilingYfhan in Wicdaus uaing apmmamdate.
inatallez
Setting up puthan envizonment x execution c puimn magun-
Releyant Coace oukcomelsS)
isplay mes.age OnscTeen
uaing Ythansaipt an_IDE
Page No.

achcal o.2
Date

in yiaite simpe Pathon paoqoom p display messagA

Resour ce ecuiged
Na.Name a Resouy.cespeihcahionu lduantiy
Compute bystem ComputeriS,
86B RAM).
2 Opeachng ystem nindous
Denelopm ent Patnon DE
Sotuuaxe

Pzactic related questhorma


1|List erent mode c maamaing in Pthon
ModesC pogaaminq inYathon cae
Tntesactive mocle
5cip made
Zexibe pacedune toexecute raam unc nea
mode 2
-Open ton inteattiue. paampt
n e ythonin putnon
pmompttuoll invoke iptenpio
e P ninkepreles_skoste.chyu can issue
onycommandas e_command paofnpt_olte zz2z
3skae ne steps invalued in Aeuing he pro m
ing SC3ipt_mode
te wita
non mosam în ascaipt ytha ek save
catensionP
Page No.
Date

2 Open phon ilerpretes, aun pxoqram


Vathan enante.py Cplo

A|3kake the procedure u make le execukable.


o malke hle eecudable in pthon_5ute Kle.uithL
OP Ctentian. ux ample ilenomepybo
thct uou
CO execuute this c pythanSpt.
X xexise
nlnte a puthon prooaom u disploy yaun name usng
nteroacHve mode.
227 mint (Teicahree dhinde
leicsree 6hinde

2 te a uhorn praom h cisple 16BIE AinC


Sxipt TIde
elep
print(MABTE")

Inpthon inteamete
aas) Cmedlenov Puthan astp ile.py
MBTE
hose P5 C\ueslenavo

I |(ompetency and mrocical skills


Jexelbp enena pase ramminq LSing Yhon tiSolve.padblems.
1Wite a impe paihon p7ogiam uinginteactive made
2 nlrike0 simple puhsn 0gaum ysing scxipt made

Revant couse oudcaynels)


isploy_messuce.an e e n Using Yyfhon scipt IDE
Page No.

Dalo

hachcal No3
Him Waite dimple puthon pmodomUSing openadtug
ailhmetic cpexatds,logical opexgtun
Bituuise opeaotors
LCompetenty and aocticalsils
Jexelop 9enenak Ouzpase moqiamming uanghon t
salve paoblem.1he paachcal is apecked udexelop
the nllouing skils=
-Wite a piomam s e hzithmefic lqical ihwise
ODexat

Re3ouKces Ue
SNo ame c Rexauyreabpecihcctan uanih
Computez sptem VtpraS 868RAM
CpescngStem lindouslo 1
Develapment iucxe Btnon IDE

Arachical qelcted queation


Mention the uae_cLkk,% opeaatrv in puthon
/ loax clivisin)Ttis used divsion d operancdy
wheie he scluhan_is c Cquatient le~t
okte nemoung decimul umhes-

* Exponent)-Vexhrms_exponential calculakian

ds Modulus) -Returs the 1eminder _oter divicing


Hae lelt opesand pitr the ight
Opeaand.
Page No.
Date

2 Mescahe exngY_Openctux in Python


eanaa Operaorg Cde _moxe commonly knaun_Ca
concutdnaul eeSSiar in Pythan.These opekoars
eNcducke sumebhing hcsed on a condihan being
he o nat. L simplyalous u test condition in
Csngle ine aeplaciny the mulhline i-elae
antax:
Gntuel if lexpreaian elke lonabe
oy example
CCdb ekeh
3Deacne gotut cliterent Locical apesakts in Pathoa
th cxppaapmiate, oxumple
nOuthon locAca. operodurs cre usecl.on conclikioncal
stare.ment. iWezent_logicc opeakus in pathan cYe

and Logicad AND)- ue i bain opezccincla oore bue


e > sand (2Ka)
Fe
>z32) and (2<g)
Tae
07 Lagica OR):Tue i t anyO woopeancs are ue

Lor (Logcad NOT): Tue iOperand is alke. 1t isuaed ta


qeNeseogAca state o its apeaand
22z pot (g22)
ahe
Page No.
Date

oaiihmehcopern
obouk ditwenent
4 Des
y t hcaibe
o n ANith_appmdaiate emplea_

operatuyleaning exiptiun
AddiionAddsboh vaues
mpleupu
operúncl hon 27 10-5
5ubbachon Aubhacks agnt
eopercnd

MhpliatenMaHiplies alues cle seet by z7 52 10


riant openand_

isan vides volue & le by iant 7 lol2|


iaon
Operond

** hpanent Yeahx Ms exp.onentcaculataalz 2**3|-

odulus Rekuana arenmi.nder ate dividiy m13 24|-


et coeran.duith cht
Hlaoz vision c oderandh where 15-
visionsolurion is oquohent et
ofter emoing decimal numoe

5 Desnne anou diwerent


aporopike _exomple Btuise
apemoatoxia_Puhos
oyenodas i
pedu Meuning
Dexiption
6itw'ise (0periokor xample
upa

copies a bt n the alo0 a l o ( l o l o ) L 0

ANDesut i t exas in both b -4[o100


opeiancs loXbl
Page No0.
Date

gnaluMeanina Dexcaptia
Bitwise t copies a bit iit_exists in Example opur
OR eitmey openand zlalb) 4

Bituoise tis unany and hcs the ekectpzzlall-41


NO Aipping bit
Btuuise copie» the. hit i t is sekin|>zzlanh)4
XOR oneoperand but not both
Bttwise he leroperandis vaue is ma 2
iignt
g h t moved iant kuno. its
sni7 lspecihed hoy the mant opeaond
LL Bihdise The opesiond's value is (CKsa40
e t movecd leYt oy no. bis
Shi 4pecihed bu the ignt openond

T
Exeacise
ikea psocctam conves U.5_dallors h Trcicn.pee
A= loat Linpur ("Enter omaunt ia 05 dolca

mnt "Rupees)
Uurpud- tnter onmount in U5.dollas: 43
324624-Kopees
3206.50 09449g9s Pupees
Page No.
Date

2
Tde a paoqtom o convert bk o 1Megcmates.Gion
ond leolbates
bit = int (input (" Enter hik"))

kb huhe/1024
mb=kd/ho24
a mbh024

Orint(hit, "bit ="byte,"htemn,"MA="abi"G8=" ibTp


Ous pat-
Entez bik: 2147480 6430
21474836436 hit23435450.0 bre 2560.Or1B=
2.5 6B0.00244&0625 TB
SINate_c mooLam tohnd tme squcve Toot o numbex
n=int (input ("enBen square numbes:")
paint ["5ucre cck cn,"is, n*á6S
Okpu
Ente SquoreAumbes: 36

Waite apmoTam o ancd ore geAe eckangl


J-osinp (" Ente lenoth.c gectonge:)
Woo Liparbnter uwdth d
ointErea o ectangle =",dw) sectanole:"))
Okpu
Enter lenath rectungle: S3
Page No.
Date

tntey uidth oectangle=25


hea cxectanqle= 32s

bite pmocaam u calcdate osa Xpeaimeker csqucxe


s Mack(saput ("Enker length.cd side ce squae"))_
pnt ("hea"s4sNeaineter"s* A
Qudyuc: Enter length_c side csquae: S
Hrea= 25.0 ,Yemeked= 20.0
6 Nsite o poqmam o (alculcke suaiace voume& agecLc cuindes.
7- loot linput (u Enker radius e cirde:"22
hlaak Linpuk("Enkeor heiglat ot cylindea ")
pmn 2314 g*la+h)"Valume=", 3.lG_41tb
Suoce Ayea"
Opur: Enter radiua o culiade S
Entor neignt ilindes 1Ss
uaaoce Arec= 628.0, Yolume =|I77. 5

Waike mocscam u suwap the vaue o huo uaziabes.


>nlaint Lioput Entez n1:")
n2eint linpak( Eatex n2:"))
temp=n
n=n2
n2 temp
int n,ni "n2="n2)

OLput Entex ni:


tnteA2 13
n1=13, n2=11
:m: · Co.m r-elen4/- ooct \½oc bccJ 6kt\ 1:s
¥ P ~-;;of pu.:po:,e, powommir13 u-?,\Dg r~on ~
~\p:m
t------1

b\e,m .Toe - pnclctco~ vs e;x,pu l-ak k:n clotdoP-----..._


~--- --1- .'.t. .Lw.. h.ill_o w \ n~ ~ :
.-:- ---- '- - ·, e, . 'n r
fPage No.
_
Dato
]
J
__j__..___

\ ~s \hcn_j{)_'J'---------------- -~
na\ 1
•1C) _\,1 .C-I . . ) __ _ _-----'-_ _ _ _...!--_ ------1

· fc1ke , ~,:-,: ec < ~ v. fus 'o\-Jch l

lI
( Page No.
[oatl3

½en cc~1J _W..-- 1-.~~- ------


2. ·.

I ( ~ '

\ - I'5

\vo''
r Page No. l
[_o_are_ __...._ __,_____,)

· ~we
Page No.
Oat1J

Lto

<o
~

''))
'

-
~ - -+ -~ --~ -· (I_~ lD~- \\ ·- 1~ ..L_l_.\l l!J~'L '~'- - - -
( Page No. 1
I l '
I!>

llj

If

cfQ.\'.Y
Page No.
Dale

·L
po.srn I~
ve '/
Page No.

aachcal Na.5 Date

Aim: Nite pxthon paxoorom to demonstzate


use cb
loopingtatementwhile' leop, o loop cuncd
TCompekency and zactica ghillsa
Develop ehesal puzpose pai0osomming vsin,
6due pmd blem Don ihon to
0/
The paactical is expected.tn.deselop tne
arite putnon aagamainauwile' loap
olcuingskilk:
Nrite c puthon aocaom uin 01 loop
ewelop aphan_poqaam uinn Neted loop
TReeNant CouzseseOutcamne.
Dexelop than ocsumtu demonatsake e apeaatox
Tachca Outcomes
Nante thon pnooram u dema1szcde e
statementsn looping
nleoop
ury'oop
'Neated' loop N

JIL inimumhesotco backaiounds


Hloopgkot.ement ollouus us execute qustatemenE
9 ou statement mukiple imes inon
moamminNonguace provides allouing upes ct
oops u nondle Uooping mequirements
allhile laap Auwhile loop stakement o alock
c
Statements Ahein atnon oiamminglanguage
repecdedy exeutes o target stotemena longaA
Page No.
Date

O Qven Conciti.on istmue


Outäy:
l e expession'
stadem.ents)
exe cxtemei) maybe,single gtademept or

block o stabements The concition mGy be alY


expsess10on_gnd me is any non-zeno vcdLehe
oop itexae nhle ne Conditonis tmue.nlhen ne
Conditianbe.comes raae, pioç omcontol pcases
theJine immedicd.ely olouing Ahe loop
Evample n O o i s v o

Count= O
cunile.Ccount<5)
oint he count is.coun
cOunt+
pint (aood ye

bhhyoop:Tt has chilih Dtedcte ove tne item


_o any_sequence ,5uch ca ddis ayc sin
Y yGy in5eauenCe
stdements)
a seauencecontuins qn expmexaion isyit is
evoluabecystThenthe Arst item in the gecuence s
Ossioned tb the ite/aknq Naialble teraig-vcy
tnestade.mes block i3 execuked.tach item inlext the
ust is oSiqnedDiteniainc-NCY ond the
stoteme
plock is uted unhl entire 5eduenLeiisehatuted
Erompewuo
pyettein non
Page No.
Date

painturent Leter lette


Cnested loops: Ython sooqJammiq longuogealdus to
Ue One oap inside anoine doop. ollowingsechon
shousew example> u illutzake tne concept.

My YaY In_secquence

Shatementls)_
St temeniy)

nested
he 6untax ta unile \oop is-
anile Opession
hileexpre3Sionriny
stode.menks
statement)9
A hna nate on loop nesinc is tnatOu
canpur
anu upe c loop inside c any otnen type cleop
EXample,
9.19
shile (i<20)
2
hile i<= lip:
i not Cil): baecuk

sv i2ilj) prinEG,Uis paime")


pint Good huel")
Page No.
Date

X|sachcal xeated questhora


ha splould he he oudpu oom ol\ouilng
hon Code Lmonono
hile Z5 hk
aint (x
-
Output: 10

6
Cnange alouding Patnon code rom
cop o loop: Ualng_Ushlle
hile xK\0:
pint lad
At=
Code uinq r loop
y n ronge A,10):
int (
Oudput: 2
Page No.
Date

XIbaentcise
4int the ollauing patteans UingJop
a

in xangel4
Oiin ranqeLi+D: C
paint ("*,end= ")

fdiiin anoe 3
in gange(2-1):
p i t (" end=
k in gange (02 it )
pmint (end="")_ A
paint ( NE

i i n range
O
2,0,-):
o in sange 3,1,1)
paint (end= ")
k in sang241,0A)E
pint ( ,end=)
printO

CLOLOo
1olol
lol
Page No.
Date

in range(4,0,-)
O-1):
h i n range 2* i-1,
nd paint ("0",end=)

else
parint ("",end=""
pint(w
2NAP to int al even numbes bekapeen 1 to 100 uAing wne
>=
uwhile zK=\00):

pint (a

3 WAP nd um_ hrst \0natural no. uuing oy


o loop
loop
Sum=

Sumt=N
pmint (5um)

Oukput 5
VolAP print ihonaccisemea
neint inpuz Entey oumber")
a0

b1
lolol

rint Leend )
Page No.
Date

b
bec
CEC+bp

Oupur Enter numbez: 7


01 2 853 13
5 MAP Ls caleulcke actomicu o anumbe
n= int Cinput Enter number)
e
ne=0:
rint Cactonicde) do o 14b/
else:
o i in zange(An+l:

paint Factonicu=" )

Oukput Eater numbesSo


Factdial=120

6 AP_ meyeme a qven numbe


naint input "Lnter numbe:))
while.Lnz0):
a* l0) + (n-10)
n-ee n/l0 hhoi
mint)

Ourpud Enten numbes: 1234


g21
Page No.
Date

1WAPhot tokes a numhez ond hod sum o diziss


nint (input Ente oumhey")
Sum=0
ahile (nz0)
Sum+s n10
n=nAo
aint(sum)
9A
Cukput Ente numbeSK7 uan
18

3WAP Ahar tgkesanumbe and checkg whetne its a


alind7ome or not
nEintl input "Eate numbe
Aum=D

hile (nzo):
= l0)+n\0)2

num-
pmintnumis padndrome)2 9Ain
pint Aum is not a palundzome
Oukput:Ente number454o
454 ispaindioame
Page No.
Prachcal. No6 Date

Aim: Waite Python pxoabam to pesbam hloauing


operaäona
LOn ists Caeake ist, fress Jist, Update Jist (edd item.
:

xemove item), Dleke list


TIICompedency ond Yachcal skills
evelop qeneral punpose pTaramminy using hon 5olue pzobem
The prochcal is capecked o dovedap tne llouing kills
NAte a paucam inq uist and penipM)_opeKcukians
dike caeate accessdalete stakemanks

ReleNant course autcamex


Pen n openakona on dakd stzuckue in yhon
Trorhcol Oukco
Wevebop_putnon ocKiamo penhm Álouing aperctians
on list. Caeate ist, access list Upclate dist and Deete liat
TMinimum Thecechccu oackonound
Aist i a calle.ckion shich is ardered and chongeahle
A list is o collec.tion o itema cor elements, the seauence
doka in o dist is orderec
he elementz items in a düst can he acessed by heiY
posihons ie. incuces
A list is Cxectecd uing UCne bauckeksl)

alreatingq dist: (rechingadist is os simple oaputing


dierent comma-separated vaues betuueen saquCue þrakes

l=L0,20,30) 40, 5o
PaysNo.
Data

ccessing list: oaccess values in dists, use the squ


bmrackets y ttsicing_clong oith index o indice

ist LL
LiO,203040,S
20

L2o.30]
aUpdating List:Vau_can update single o7 muliple eemnt
c listby qavinu ne slice on the let-hand side c
he aasiqHment opexrcto,and yau can add hu eleman
in a dist uh he append)mehoc.
LiO 20 B0,40,soJ
222 4lols60
LGO20,20,40 ,so

RWe con add one item tu aist using cappendU meitad-


c add seNeNCl iemalusinq extendl) method.
z ldi= lo,20,30
77 listi0ppend CAa)
2 Jistietend (Lao,zol)
22 list1
[io,20,30,40
60,70

isWe can abho ue


topexatoz to combine two dis hs
obo caled cocatenatlon
list4Lto,20, 3ol
Page No.
Date

22 listi+ l40,5O,6o
Lio,20,30,40 SO,60)_
iThe * opesciror epeak o dist cven no. o items-
>2d2=l'A B7
>2z d2* 2
[AL,0A'LBT
ivJlnle con inaent one item at a desised dacation 4 uing-
the metnod inseaBQ
2222lo,201L
2z \2.iMeat.iL30)
ClO30 20

dDeletng ist oemove, a dist elementyou can ue


elne the del statemenr iY uou knou excicty ehich
eementls)ou gore delein g neiemave.lmekhocl it
au do not koOu)
ilDa Operaton Ne con deleke one or rmoxe, itemg om_ca
dist usinq keyulord del Tt can cleke list entirely
22Jast z I0, 20 30 40 50
»2dd uust [2)
>> list
D2040,s0

iRemove opesao Ne uae ne qermove opescdor i


e know toe tem nak e yNant o semove on celete
hom tae dist.
Page No.
Date

e.qist z lio,20,30,40,50
i t , KEmove (30)
>>list
Llo 20,4A0,so]
xaacicalaelated_duestian
henoto udee istz
Lists ge used to sture mulkiple items in_asingale yazriae
Ahey care used u stome an oydered callecion_cin
wnich night be cB dierent upes
2Descioe voiou ist unchon.
append)-Add inale_dedtent he endc dist
Cop JUTM_a shculou_copy c cust
eod)-semaves al itemg om the list
Count aehins count o eement in the dist
xtendO- adda idetable elements tu the enc c the Jist
indexO-setusna index c elemen in the usE
inestO- 'msest 0n elemenk c qien inda
Spop Remav e oleme.nt a avèn indea
Temovel- emove item am the oiven Jisk
sexese - evese the clisE
SDt U se1s elemenE a dist
3 ite
dusk Yem.smaxNOmethod tu COunt
occusencel
slcouat)15 on tult unchion
cOunt c NOuD On mes inOxtnon tnctgeund
a cven dovect oCu inu

name- count looject)


Page No.
Dale

Ho to concatenceke cast
>Ta cancatenate 2 dists t opescukox can be wec
d= i ,23]
d Lp,20,303
Ja
C2 ,la, 20, 30
sTusti he statement Lists are mudgble
Lists ne mukable oecase ne yodue c anu elemen
iside the_list can he changecl ct any pin o ime
rarue

Oexaibe the use cpop opet ar indis


Vop) i5 n inbuilt uncHorm cv putha0 thcat semave
anc xeturns vast vaue om Xhë Jisk gx the
lis given index value
suntox
inonneof aplindex)

eqlisth e [1,23.4,S
print list pop)

2
> Jist
L , ,4,s
Page No.
Date

hHo to concatencke cist.


0 concatemate 2-dists t opeckox can be_ecl.
= ,23
o,20,3)
J3-dLtJ2
J3
L2,G,jo, 20, 30 J
Susti the statement Liss are. mutable
istk re mukanle be.ccsehe ycdue c any elemenE
inside the dlist can be chongecl ct ony psint ot ime
Oecoibe the use cpop opeCLt aindist
Yop) 15 n inbuilt uncHon c putha that emave
and retuzns ast value rom Yhë isk_x the
ven index vaduue.
Suntox
Jistnanae poplindex)
eqJissA l1,2,3A,s6
print LlisApap l))

i)s»istapoplA)
2
s Jist4
LL,,4,s1
Page No.
Date

Txescise all heitems in


adist
NAF tu sum

dal45,61,2113,50
SumeO
r i in di
Sum+sL

print (sum)

olp -196
2 NHP to muliplies g the items in c dist
Ja[s,310,21L
SL mu=11

Multe
Print mul)

olp: 800o
3WAPp oet Ane loxgeat o. rom a ust
l ls3 3,24,32T
eszl[)_
o r iin d:
loroe>t<i
dozgest =i
pint (Josgext)
olp: 78
Page No.
Date

4WAP o got he smallest no. rom adis


Lá7 a4.12,90\
rint Lminld
Olp-12
SHP tu sevease cist
=[a'b'ed
.revemel)_
pintd)

Op: d' b'a


6WHP o ind common itemg rom wa lists
Ji=[h',3,ab6i
d2el6'pqshS
PitCommon itema aom dA gl2 Jist one:)

o in 2
iviejprint (i end=" ")
Olp- (ommon itema rom 1&l2 ist cre: hik.7

WAP o select the even itema c a dist


LL,S,9101
n i in
i i 2 E 0 : iint )
Page No.
Date

aacical Na7
Pim:waite pthon proqrom tpeahuzm allouLpouL no
opexcuions on tuples Caeake luple, Acegs
Tuple, Updade TupleDelete Tuple
LCompetency and iadiCal 3kills
Dexelop ënesal urpose pTOTamming UALng thon
salve paoblemhe rcuciccu is expectecl to develop_
the allouwingskills
hWaite a pyihon pxogsom un tuple

Rdexant Couise Outtomels)


Pennam opesahons an dato suchures in puthon

racticd Curcomen
aite phon pmam peaÍMIm {allauitng opemcicns
On Tuples
Creake luple
2 HcesSS uple.
3 Updote luple.
. Ddere Tuple.

Mimum Thaotetic packgroounc


H huple is a
seduence c immutable Putnon obiecb
upes cmesquencesjust Jike istsThe daWeKencos
beruweern uple ond dis a r e h e tuples
e coanaed undike Jist ond tuples canna
here a i s s s e square uue pgo Panontnes

oTeatlng luple:nece tuplepxackeks.


py puin
Commc5epcrated yclue petudeen paranthesel-
ehipi-(1,2,dbepa)
9RE

Page No.
Date

h e empty tuple is mitten oa tuJO pasanthessea containing


nothln q-
tup2-

bIHccessing Volues in Tuples


O acce>s values in tuple,u8e thesqudze bxockek h
Sliang along wlth tne. index or indicex u obtain value
available at that index
etup\=(1,2,3 4,S,6,17)
Print tupl [o1)_
rint (Hupi[4:5])
olp-4
[2,3,4,s
dUpdahing Tupex. uples oTe immutable which meas
able
you cannot updute tuple element,but uou Cre
t take postians c existing tuples o caecde neu tuplea-
2g tupi=u2,34.56)
tup2=('obc ayz)
tup3= tupl+tup2
paint Hup3)
olp-(12, 34.56,abc,'ayz)
d Delete Tuple Elements: Removing individual uple eamers
5 not possible.lo xplicity remOVe an entire tuple, just
Uae the del statement.
e
tup physics','chemistny 1437,200o) ;
i n t up
Ce tup
Page No.
Date

X|rgcical gdated questions


Deine emphy tuple.nsie syntox tD CIecute empw
Emphy tuple is tuple with no itemx in itTheeemphy
tuple is written c tuuo pazanthess contuinlng ininqodn
yntax
fuple-nanmes D;

aite suntax ta copu speciic oemenks exioting hu


ina neuð tupe
neuplee 5untox
Newluple= eisting luble Lunge
e
e.qtiell,2,3,4)
42=[:9
paint H2)
Dp (23)
,L
Compave tuple ith ist lany4 poins
Tuple is
Tupe stuse dcoa in )hackes Hlistredasa insque
uple s immudade Listis mutable
oume le>s Mem oume mare menoy

Tuple doe not have Mony ist have geves huil


Duilt-sean in metroda..
metnods
vea 1=l1,2,3) eA=[i,2
nednnmn -
Page No.
Date

XLLxemcise
e a e o tuple cnd ind the minimum anck MadMum_
numbex krom it
t=S6,12,34,34,9L,671)
print ("Maximum Volue" inH)
paintC1Aaximum Value:",moxt))_
Olp: Mnimum Valhe: 12
Maximum Wedlue q1_
2wAP u nd ae epeaked itema o
t ,2.3,4,214) uple
in t
tcount li>LL
printli end - 1)

Olp- A 4 4
ont no. in uOYC) nx exumpleN= Cne Tuua Three ay
t=zeno" "0ne, "TTheeu,"heSix",5een' "Eht "Nine"
nEintLinpuH"lntes numbe)
X-0
whle (nz0
lo) +(n /b

while (zz0)
Print(, erd =" )

9p: Enker numbes153


beven Five ee
Page No.
Date

rochcal Na9
Hum. Worite python pr0030m u perorm allawin
operatiana an Set Cneoe su,Hccess Set eleer
Ments
Updae k,Dalete Sot
Compeken.cy and Prach cal 3alls
Jovelop qenexal purpose poaaam.mlng using hon
salve proolem. The porcucticalis epected to deyeop He
olousing kills
hlite a pmagsam uaing e t and ensiomb openatian)
duke create acce5updoke ad delete

TRdevant Couxse Oukcome )


Vesoom opaians on datasxucurea in Phan
T-racical Otcomels)
Develap patnan oraaram toekrm lauling opesiokig4
Onseks: Caeade, Hccesspdate and deleke set
II Miimum heorecticad backqsound
Mothemahcally a set is a callechon a itemy nut in
any paThcular Oxde H puinon set is simlam to
this manmaical deñnitioH pith bdou addahonal condit
The dements in he se annot be duplicotes
The dements in fhe seEgre immutadleLcanno b
modhed) bur tne set os auhole is mutoble
There is no index attodhed to unu_
element in u
RAhonSd So hey co not supp t anyindeAD
Sicing Opom.ahon..
The sos ihon oreupcaly Aed or mathemdn
ooenahons Jke union intersec.hon dilenene
Page No.

Date

and cOmplement ekc.


alLaeahng aseti h set is caeated by uing the sal
hinc.hion oplacing gll Pho olements nilthi d pay O
cunly a c e .
ea >> a=113.5,421
pint ("a-",a)
= l 2 3,4,S
>> paint ltape (al)
<dlass 'seB's
b) Hccessi.ng yalue in a set \nle cannot acces indiviclu al
Yalues in a set Ne can only accesS a he elemens
ogaihe but We can olsa qt cudist.o indiviclucl elemenis
ny loopi.ng thouch Hhe set
eq Num =det (L\0,20,G0140,SoD
h Ain Num
Dint (n)
Oukpu 0
40
SO

c Opdahng tems in a setmle can add eements Au ase


by uAinq odd mekhod hee is o specih indei
oktached tu the neudu oddecl ekement
e um=set (l0 20 3d,40s0)
Num.add (6o)
paint (lum)

Oukput 0 ,20, 30,405060


Page No.
Date

djRemoving items in se
discor dd
NG can xmove dements om_dethy aing discay
method.hre is no specibindex aktache.d to th
neuuladded dement
q Num- 5ekLCio,20,20,40, Sol
Num,duscac (S0)
Yaint (Num)

Oul pud la,20,30,40


Xa.chcal reladd Quesio
Dexcaibe Hae vamoud set apeauhon
Opcoohion on St
Oniun la qer cul elements anich Cye in both seEoza
2Tadeacsechon lo act.all elements ahich are in ouin
3 DiWezence To ae element wh.ch e in one sot butrt
Summeknc dikoren.ce lo qek elemenks thcu se alhty
i nJst se ox in 2nc hu rot in balh

escbe vaqious methads dse


add)-adds element y set
cea) Temove cll elemenb rom csek
coPy ekuan shgulou copy c 5et
dlerence)-netuan> diweren.ce a twosers
derence- updcde0-0pdcescalling set wnimezsecton d/s
discasdD-Removes Cn_element hom the Se
intosechiun- e t u i intersectlon c two ses
iscisjoint -checks cisjoint seks se
i5subsek ) - chech i a set is subset unathor set
issubse

i53upeset
O-checka i a set 16Superset dgother e
Page No.
Date

popOsemoves an cooitza elemen


Temovel)- emove> the pecihed dementE
3ymmetzic.dieren.ce L)-Return symmentaic dkerence d se
unionC)-geturns the union o seks
Updade O-add elements the set
X encise
ANAP Czeate a getadd member (5) and semave one
Atem rom se
ekd-sekO#aeated set
3ekadd(2)
sekl update G5,) #addec
members
raint (" Sels"sek
sekl. discord (S) Eaemoved one ikem
print ("sek4' se )
Oukput seBi 2,3,s?
set1:2,33

2 WHP tu peimm intesection c sesurion c Seks,


5 diemence summetic cieence, cleoy cset
si5085, \o0,2s9
52.e2S,50,200,lo0 1
paint (ntersectlon dseks slintesection s2)
paint C Vaion c seks:"sLunion 62)
point ( be dikemen.ce.",sditlerence(s2)
pint (bummeknic cukerence ymmetrnc.dieaence (s2)
5. clear)
int al)
Page No.
Date

hersechon c seks:2S,lao
output
Union c sets 100, 200 50 3S,25,604
Set ciesence S08S 1
3S,so4
ummeic dillerence 200,S0,

3WAP u hind mcximum minimum value in Cse


seklG4,21,g410,92,73134
pziunt (Mximum Value: " mcxlset))
pint Minimum Vcdue:"min lser4))

QputMayimum Vcuue 92
Minimum Vcuue lo

4WAPo inddength c o set


Slabi,Le
print ("Length cset:L Aen (3)

Outpu Lenath c set s


Page No.
Qctical Na. Date

Naite Yython paoomam tu penmkrnm ollouing


opeokions on Uichonomex (aecde Dictionu
Ace3s ictioncy Update Dictioncmy, Neete Dctionary
LoopAn hrougn ictiona
IICompekency and Paach.ccu dkills
Vevelopqenera puzpose proCkaGmming sing thon
to
Solve möblem The p.acticad is expecked tu devdop
the ollOwing srills
Write Python Pragrom uing Dictionay
Develapsimple it
application yaunq Dichanan

Raaxant Course Qutcome(


Yexmopeorakiona on datcastauthurex in Ytnon
ysacthccl Cudcames
write Python poqaam to perm allauwing_opeaati.ons on
Sichoncm es:
1.Crecue )ictionan-
2 Acces Dichona dements
3.Updae DictonCo
Delete Dichoucay
S Loaping throun ictioncy
L Mipimum heoie Hco backgsOunc
Ython dictho namy is acontcune_ a key-vculue pcirs
muteble nd cen contcun mixed pes Adicioncay
is an unOrderedcollection colle.cian Yutnorn cichoncnie
Omecdled dagodokive Cmays07 haah tade in othe
immutabe
Aonauag. \he keys ih c ci tioncay_mut be
Page No.
Date

object ike sincs_o nembesney muat ako b


unique within _a dictiono-
al Coecing ne Dichona
The dkchona can be cxectec oy uing mulhde
kevouue poas _endosed i h fhe small brackgts ad
sepasaded by ne colonli)he cellections h e
key-value pcis xe endosed [hun fhe culy bmaekes?
yntax
dicE Name Zarc Age':7Llaas" i s t 'f

bJAcesSing Valua in Diciona


To access cictionay eleimen s you can uze
he amiliar sauaxe hxackets_alonc uith key do
optaun its vclue
eq dict\NarmeZazaHae:, Clos kist
int "dict Name dichName
paintdict LLge clicHge'
cJUpceing ichoncM
ou Cun update d dichonam bu coding aneienty
03 a key-Ncuie pcu Modin an existing enay
0Y dekiing an existindCE_en
e.q did AgeE8 up.dade exising eh
dic L%ho ) P5 %noo d d neud en
d Deleke Dicionay ements
oucan eilhesgemave indaiducd dictiona
elements qr clecY ne entve
contents cr
ou can olsa cete entise dichona n a clictoco
o.expluctly qemave an entire dicioncjust sagle opexo
ue del.staten
L.
Page No.
Date

e de dictName', #remaye enty uáh bo None


dick.clecr O # aemove
allentmes
del clict t delket entire dichonam
e Laapiing thiauan ictionay
Adichonco ccan be tesated using he or bop.
u wa td qet pota kes and vaulues in ouau
tace keug 00d Ngmeg cu be oKCmenk _c
point stakémen in com.ma seposcidn. Htez euch
erodion_k laapou Lill et both keys itseNanE
NCes in the outpct
e e n keyvalue in cict.items)
pint(key alue)
Xrctical Relakecd ueshons
WhaE is atpt o tollocuinq pmgTam_
kput MOTE
Nametxa name lelichignGe is nat_cdeincd

2lbotis output allauwine paogsamn-


Oukput Goagle 1
Focebook 2
Micxosat 2
GFG2
Youtube 3
Wha is oukpuk hollo.win procram
Otput: &'keyd AGke 66L2.3,4_
Page No.
Date

XL|xeacise dict
lascenchngandldescencling) a ctionaoy
WAP tu do
Dy vaulue.
d i e ti = { a 4 , b 7 ' 2 , d ' s

Lcicti ,key=clicti.get)
Csoded-kes goxted
-clicti}
iain a-s0a ted-kes
a-dictl=dicti[
paint (Ascendina cichoncnay a-dict

d-soted.keyadorted clictA ,key=lictiao, zevede-


d-dict ES1
DY in _d-soxted-kes
d-cuctil> dictiL1
aintDescending_dichoncry"d-dict)
Oul put:
scendhng dichon.acp 12a 4,d':s,h':1
Vescendinq dictionaga b: J5':4:2
2 AP o concatenate D\launq dichanare to
a new one
czertt
cteiL0,220
dic 2= 8.30,4: L63
ne eic=
ne dictpdgte CdictA
neu-dictupclode (did2)
eu-dict.update Cdict3)
ntneu-dict9)
Page No.

Date

aJnd ID,2:20,3.30, 4.uo S:so, K:60


HP tocombine uws dictionamu adding vabues
Common e
- dl=i'a'loo,'b 200, :300
d2 a00 b 200,d' 400
dacict (d)_
dupcdateld2)
0 key in de:
i rKey in di
dslk dl[key]+ daTke
pint Combinecd dicionazy d3)
Output
Comoined_dictiona a'100^bl:400,c':300, 1d':40o1
AP o knd ignest 3 valuey in a dictionapy-
dact e40,'bl:73,':12,d' ss,'e'23, 32,a'i251
sdict soated lsek LdickivalueaO)zevezse- aue
pint("Hineat 3 Nalue ane sokctL:31)

Oukput
Hicnest3 values are: L_32,73,5SL

kWAP to priat a uique Nalues in c clictian


leIfv%0013,Ay:koo,s00s, SV13005),igr:`os},ÍVIT:S007
uniquewaluescsetlul ny
diin disti or vol indi vodual0
Pin"Unique vclues 0e"utuelaulunes)

upt. Uniaue values cR00s5007,s001So02


Page No.
Date

Pzazhal Na40
AP w ademosake malh Duilf-n huncio
nong
Him:
WAP t o demonstzake stmng Oul-in unchian

Compekenc4 and actcu Skills,


The mactttal is_expected dewelop the hllowina
inchon
Naite O procscum usincMath bult-in
Nnteap04sCm uAin Smng Oullt-in hunchon,

IRleNant Cource Outomels)


Vexelo anchong nY qiven proble.m.

Practia QukcoMe
-Noshe Rhon proocsam o denonarate mom bilt
unchon
ite man piocmam tu demansuake sting buit-in fa
T inimum heome Bacsosound
Matns huilt an unciana: Here is tae list a ll Hae
ncfio nd kmhute, detanecd in makh madule

unchan DoacLphon-
ceil lA Kehum he cellng.vadueTis the smolles
iniege,Terter gy eauol numben A
Copusiaala) Ketun a úoirh the siqn_oy
COs (n) Retuyn the cosi.ne c i
Keturns e*a
ocuria la) Reuanacctoial o
Ketumns gest inteqe less than y ecu
mad a euma remaùnde hen x_is dividka
Returny he qreate cotmmon_ clivisaY
Page No.
Date

hunctian
lag aLbose escipion
Rehurns the log cawhere hase iscixen
log2))_ Relurna he log awheze boae is 2
loglo (z)_ Retuyny me log a where bae is l0
Rerung the in the powey Naue
aemindela,y)| ind remainder ate diuiding yy-
Tacians la Convent angle Mom_deomee) to IOdian
inds the suare co cr 2
sin( ) Rerurrs sine ca in roaclan
tan ) Ketuns tne tangent a in adian

Sting build -in unch.ona.


tnon aclu.de oll.ouoin.g bult in methods to manipulcde staio
Fundion Dexxiption
contalire )Convets tne Ist characte uppezccue
countO_ Rekurna noc imes specikecd vauue
occu in àsmng-
enclsith() Kekuxng me ighming ends wito speciied volue
and() Deaschestang wy aspecihed vake und
euaay positiOn uwmese it uwas toundL
index) 2ascney_staing value and netuzns pasiion.
r
isalnum0 Keurs ue itallcharactes in shingae alphanumedi
salphcLQ RetuynTueikallchayaders in sting e alphabek
isdigitL) Reku hue iý all chauce e_cigis
Rekunsbue ib all chayodesare locae code
isouuè L)
pumeri
ISnumeric) Retur ue i all characteg e
Rekurnsbuei cllchoracre
me whiespa(3
5spciceO cone
1Suppel Rerumabue iball_cnaxact oreuppe
Converts staing into laune Coe
doue
Page No.
Date

uncion- Jeacaphion
replaceO Retuma_a shing wheae yculuue isreploce i h
Specihed vciue
ind Secorches string yperihedalue Xreturna lcg
osiion_c whee it voA Hund.
inda search smng arspeciigd value x zehuny lo
posiion ahece t o u KOuhc.
splt) splis stmng ok apeihed sepoakoy & etuiny al
Strip)Kemoves spaces at beainning at end dsing
StaztsnhhU| Rekuny tmue i saangshans vth spekec value_
itle) Convets 1st chaacte o eachwOYd tu uPper oe.
tranuate Reurpa ranslated sing
uppes|Conves a sAng iodo uppe CONe.
Xacticcd Relcded uesion
Cascbe about sting hamoti ng openadoy itn cycmple
|Phon Mes C:shde sting omatinq creake ne,
wmmatted sbins\he "ope«ator is aec to
hxmat aset d vaoriubles, ogethes iuth a himct
ina which contains n0rmal tot tugether nuth a
mat stang nich contalna noYmcl text ogethe
i orgument speciies, special smbls Kke
eq print ( ny rume Is 7s ünd age_is 71ds
"Elejalme
ZGive the suntaaand exC1mple c ilel) &captalizel)melho
Hel): synta sting.titlel)
eqet:" My name is Aeicaxee"
oi(teat.ttle (O)
>My Name l s ejashree
Page No.
Date

2capilalize )
Synta s capitalize O
st=hlloa usorld'
pintstz,cap idalize0).
Hellocuod
3|Give the unta and signcance dktleO stipl)
titleDThe ite) Method metur) asthng th 1st
Lette each aDod eapet copitulized.

|21stipl): The saip) methnoc rpkuink a copu the


sing bu emoving both Hhe leacling % rail1ng charaded

XLeUse
WAP hat acepks a shmnq ancd calcuake the o.
uppe cese lehes and ue cose lehea
de calealakeCi
sBi=input "tnteastang
uPpe 0-
doue= 0
c i n sr:
Cisuppe :
pper t=1
elib c.isowe):
Jower +=1.
print"No. ouppe ccse detenupper
Paint No _o loueCcse lettes:"awe
Calcucke)
Page No.
Data

Oudput
Lntex a shing Helo wbrlc
No Uppe caAG Jektes:2
No o louwe cse dettes8
2 NAP tu qeneccute aundom foak vnwhere the value.is
betuneen S and S0 using putho madh_madule
import gandlam
painE (oandam. uniaamls,so)

Ouput:
7.15A44 35 219 287

.
Page No.

achca No11 Date

himlJexekop uber dehned uthon hanchon or gven poblem


unction ith miolmum 2aaqumens
unchan xetung yaues

rattttt SiqAiicanee
TVRelevcAnt ours Outcame
Levelop uncho na or Quen prdblemn

aciccl Jutcome
Lexelap uNe dehned puthan hunchon Y given nobern
1 tunction auth miniñum cxaunenk
2 hunchion aetuMing values,

ILMinimum TheareticaBackaound
Hunchons ge Pne mast impoxtant cspect o an unalicahon
Aunchon ccan be deined .cs ho crqoinlsed ylack e
zesablecode uhich.can be calledneneveequred
alzeahng a hinchon Tn thon vwe can use deE
Keword fo deine the unchion

de mu-hunchon O:
hincho0-Sute-
TekuYn <expIeSslon >

bLling a nchon To col me hunchanuAe Hhe hunction


name olowed by the paKanthese
det eeloee hello-uord)
int hello uworld")
nelo-aorldL)-
Oudputhelo wald
Page No.
Dale

dJetunn 5taemeot he statement sehuinLexp7essio


_expsessio
exists ca hunctioa,.optionally passiag back an
t he cculler. H ekurn statement yufh_no Ciqumen
is the ume_c netuan None-
bxmple
de sumlaqi,cenq2)
ptaul-cgit oa2
int " Tnside the urchón"tpral
Tekurotetulj
total=umlo,20)
pint"Oukside the functon: taral

Output:
Outside the unchun :30
xA achica Relededl Cue>tiea
Whak is ouput hlaujing proçqaon
de muuncltext,num)
hile MUMZA
hintLtext)

OuM: pum-11
muhinc (Hello,4)
Hlla
Hello

poins Hello intinite kimea


Page No.
Date

shais output ol olouing procoam


num=
de hurOD:
Num= 3
pint (num)
ung
pxint (num]

xexcise
ite mon hnction he okes a numbe o a
pugumete ancd check the numbe is pime oz not,
deoime Lnum
hr iin ange (2 num
num i ee0:
retuYn "Not c paime AumeN
xehun TE is prime number
nt Lpiime.li9))

Oukput-
Tt i5prime numbed.

2 WAP colcudate he actuyial er anumber (anon


negahve intege Ihe unction aueps no cs an avqument
eact(num
i nums0:
TekuynNegahve Nume l
i num=z0:
TUin
1
Page No
Dato

elbe
Tetuyn num* Yact (num-1L)_

Print (act (s))


Oukput 120
Wite
Wte aa pthon
pam unchon that ocepts ostnngod
Opd
Calculate the number o uppe cCse uettes and
lowecase lettes
del colculcte.(s
upper0
Owe-0
ar i n gt
cisuppesO:
uppe+=i
eit cislaue)
paintNo c uppedicose lettezs ppe
int No louwed caseletes:"gwer.

caculute Hollo aloslo")

Oukput
Mo upper cose lettes: 2
Na d loue cose lettes:3
Page No.
Paracica Nol2 Date

TOCompekency and Paatim skills


evelop ceiead purpose procsum.miing Using Kthon
Ahe aical is expectecd u-develop Hhe olfouing skills:
AP o crecde built-in module
WAP xeate user deined nmodule
Relevant Cause ukcome
Dewelop nchions ar qaven problem
Iracicl Oukrtome
Wmte a progscam in thon to demonsycte uue ct
huilt-in madule (eq-keyuoxd,mcth,number, opeyadtuy
2.Use clehined module

IMinimum Theaehcal badkgsoundl


a buirin Mqdules
built-in madules cre uuitten inCancd intecacute.d
with ne Puthap intempxeter kach huilt-in module
Contcin& rësouYCe oY cetcun sastem-speciic
unctionalitieg sudh cu OS management +eisk TO
keyuod math numberopectoy ekc The standavd
Uibyay glAo contain many hon sCipts (uith
he
cdist
contauning utilifesIo display
exrenion)
olloung cammand
C l cvailalble modules use ne
i ntme Pthon congole
> >hep (madule)

blPthon--Math Madule.
popuday mahemaukicc uncians e
Some o the Most Module hese indude tignGmetic
ceined in the mcith
Page No.

Date

nnghóns,repxexentation5 logaithmlC ncio


unchons_etc n addukian tuo
Cangle cConveasion Fuless numbe
Lonstanb
Mcathe mahicalpie cund
clehned in this mockule
arealao
Excimple
mcuth
>impoy
2>> moth p
3.4IS4265353G793

cPthon-05 Module many


automcuicallypenwim
Tis possible u
tcsk&he OS Maduue in python
opercuting sustem
mnchons a r Caecking ancTemaving
movides
olcdes), kekchina ais its Contens
a diaectuny c u s r e n E cirectonL
changing cuncl Iclentiyhng îhe
Example. creake
mkaiy O funcian o0s madule is used tu
ne clirecton
>> import O3
> 05.mkciz (" d://tempdir")

d Punon-Random Module
hunchosi n he Kcundom lodule depend an apsed
undom no qeneNCAtOYunchon XandomO,uhicn
aeneores Yibodnumbex bekuoeen 0-0andL0.
fxop Andom
2 2import aoandom
22 t Tondom.andom)
O.64517634807593
Page No.
Dato

eUse-deinedmodule.
The uer-defined module.is_uitBen hy the U_okt
he home o p1qiam
JGeahon a Uaex dehned wating-
o Caecke amodule juat wzite Module
o Pfhon code in c-
Pale im äle extengion o
PH
madulenamea Pyis crecked
dek_aceptintd
val=nt linput("Plecae entes cny intece
Psint (The integ.ex vGHe is", Val
ihcessing a Usem-deaned Madule
Ne ace>s he madule hy uing tne impat stakement
anmple
impoa he module in Puthon
inapozt modude-name-

Cutput
lecse entes any inteçie:22
The inece yalue i 22
Xrachcu zelated uestianu
N e outpu c olouuin
impotmath
mint mcin6qmt(25)
Orrint mothapi
int matho decree
i t math.odians
pint Mathosin l2)
--
Paga No.

Data

print math.tan (O.23)(4)


i n t math. actozial
34lS92653589793

114.S94SSY02616464
0474g7SS11 96S976
O,s092974 263 2S6 817
O 8775B25%18403723
0.23414336 235146527
24

2Whatis output ot hllaaing aOaam


impart Iandomn
(0,5)
paint zand om.gandint
)_
int ando.m. sandom
pint (nandoma undomO& l00)
List 2L l,4,Tue 300,"Pyhur27," hello "
Print Laandom.choice LisE ))_
3
O.27363 826822762 68
70. 6004IlSS26 2366

hot is_oukput allouoing proq-ram


imps_date ime
om datehme impat dake
impont time
paint ime.fime Q).
raintdade romtime.stamp (4s4SS4))
2145412. 3927538
1970-O1-66
Page No.
Dalo

X txenase
HP o eate a usen dchned madwe that nill 0sk
LyOuT Colle.ae name ond aill display name
o colleg&
de pit clg 0
del

C-namee imput (Ente


collecce name:
i n Youy college name
isc-nume)-
modnfPH.
impozt dg
dgapainkdq )_
Oukput
nte Collece name:Npms Polutechnic
ouY calege name is Vpm's Paykechnic Thane hane

2AP tho uwilL caculale Hrec 8


eireunstaciiaumkerene
d cncle udng inbuút Math 11ocdule
import_mcath
E oat Cinput ("Plecse ented a.dius acirle )
2*math.pi
C mauih pi *
paint Circumerence=",
pint(Hrec="C)

Oupu
tnte aadius o o circle5
Cncum rence 41S3653584 793
Hsea c cicle- 13.s3%1633 A74483
Page No.
Datn

WAP that olL_dhsplay_calend.a


gaven
gaven_mo nth
ing caendux mocule.

impaxt calendor )
i n tinputInteyear:
n))
month:
m= int(iput (Enker
print (calendaramanth ( y m )

Cudput
Ente yecr 2021
Fntex month 5
May202

Mo Tu We Dh Sa bu
2

l0 13 1 5 16
17 1819 20 21 22 23
Q42S 26 27 28 29 o
31
Page No.
-rocical Na.13 Date

Aim mlaite pytnon pmaoram to demonatrcuteUec


built-in packages Ceg Numly landeu
YJer deined packages
RelevoantCourse Outcome
Dewelop hinction or given rablem

ractical Oukcam.e
olegite Puthon roqcsam tu demonstrcke uae
auilt-in packageleg Numky Pandaa
Use dekned packa.ce

M Minimum heore.ica backTaund


Numy uuhich atands ar Numeicol Patnon,is alihiay
conaisting mulHidimenaiancul-arciycajects anc
colle.ction outines hr oce>Sin a mase cirzCus
Using NumPymathematica and loical opexcions
on coxaus cn be pemhomed
5teps a nsradling umouin sindonlá OS
AGotoCommcnc iprampE
Lancammand pip iutal numay
>imp0t numpy Csp
aEnp. OaOLio,20,30,40,SOl
22 pqint la)
i o 2o 30 k050J

Aample-
stucent= np.ctupelL(name.320').Lag)Lmaus 4)JL
222aanp-ooyCVija 43,90)KPvaxad 38,0) dtupe -saudent)
Page No.
Date

Lxomple
int La)_
uo 2030 40 S0 6o
aspapel23)
L1o,20,30
Ab,5D.6o)

Caeating and acessng a tnon ackgue


5teps4
1 zeete c cMrecm
Digecto namelas
2 Rt cdosse cnd zecuired lunchona in itE
Klenames lautipy
class Mcmuril s
deliiklseliann
sel.modek200Au,llogonR
det PMadel (selt):sd
rint 11odeb c Moruh")
model in selmodels
print(tZSJmadel)

3 anally sae Create an-init-le, n lepython


Knounak theirectony is podKCIqE-
Hlencme init
somMamtiimpaz azuti

|4 Hde2s pciclkuste Cax


hlenamessumplep-
roaAcind irppoa Mamh
Modd Meuh Mcaauhi
PageNo.
Date

Madellamuh PMad.O

Madelk Mani.
S00
ledoernk NagaaR
XHeachicc aeaed dueslions
ADescibe NumBy Ha
obiecs ca he same upen memom it ia an -
Obiect which points tu a dock o mema eeps
ock d upe d data stozed, keeps autk dY houd
Many_dimensi.ans cze here cndhou \arge each
one s cand impoatamyhe spadng petuoeen
elerments along eich AS

2 why shaud une use Nunmu aatne aea Tnoan Matlah


Ocrae0x Yomick
Num?y is mec o (xecuing homogeneau -dimentionad
aia Numly provides eácient_stmiane qnd hettex
wCa handling data or Mathemahc.cu Opeahons
tnon is open-souYCeit dont_cost anthin4it uses
Aneropuxpo.se
c A g . eand it iselcuively ecay
connecr exisihy Cand FORIRAN cade tu thepathon
Indezprcke Hendë PMmon cand Nuky is uaed
sane nan Molah Octave and Yock.
Page No.
Date

Xeacise
olHP ucreate Lmaddces ancd pesnim oddition
Subtiacion, mulipli.cahion and division _opxcion
On makbix
impait nump
asnumPyaoioyLLI4,3)LISa)L

a=nump muy Lis,4Llo,d1)


i n t (Adihan
printnumpy.audd la,b))
pintáubtzuchan:
point numpy aubhactLa,b))
print Mulplitahon:")
pint Lnumpy.mulHply (a,b))
print vislon
pxint Lnumpydivide la,b))i
Output
Hddihanà
Lt6 12]
1SIS11
Subation:

Mulipli.ccuhan
[ s 32
(S6S4
iwision
Lo.2 2.3
Page No.
Date

WAP u concabencde uoo sings-


strlainput "Enteo sbing"
st 2- input("tnter shing
s3-sBrltsr2
pint(str3)

Outpur mtexr 6hing hello


Entes 5Bir w0ld-
pellauooald
ate lumnly praqaum t Ceneroke slx iandom
intece peuNeen \0 Ao30.
impa+taumpy0Ln
C np.TONdoMyadintlouu=\6, hign=30, size=6
pintCa
Output L 22 25 13 29 18
Page No.
Dale

rocical No
demonataate
Him \pite a progom in Puthon u
olloun OpenatonualMefhod ovezloacing
Metnod avericing
V Ree.ant louse Cutcome
Denelap unci.ona r cen pioblem

Prackical Cudzome
olate a proqam in_Papho deman tcte
llaudmgoptcuhiona.
AMelhod ovOlocding
2Methad ovesaiding
I MinimumTheozestical dadscound
Mexnod ovedcuding
vearlocaeamahoo in thon,se,aeed ciste- -
thea mnethoc \ogmc insch No tho dependung4-
upontne paametea pased o cuWesent phecë
o code executes insldeme mnchan hx eumple-
deas shudent
de belo lsel nc.me-Nane):
i k name 1s not None
p n t Hey +name).

pinrHe)
Std=5hudent)
5dheloO
sdLaad2
Page No.
Date

Outpud:

He PacLAad
Method CNeoridin
Ahe method CNencinq in Yuthon mecias_cecuting
uo meinod) sitn the same nanme but ditwey
Mpr0gEomminc dacuc Thne concept a Methoc
gMONYAding ollaus u p chanae ax overidee
he Parent closs hunchan in he Child Ccus
aample-
c s tmplaljee
del mesage (selP):
pimhís mesae is om troplauee Ccu
clas Departmnent Emplayee
-del message (selE)
pzint ("Ihis epatment lasisinhented om
mplayee
empstmplayee)
emp.mesage
pont
dept= 1epcimentU_
clept. messue
Oukput
his meas.aqeIS TOm tmplayee Los
Ihis Depoimeak daasis nheit ed rom
LmploaQR
Page No.
Date

XPracica elcteçl duestions


1 5tete the diiWemencepehuueen metmod oveYiclind
nd meknac CNedageing-
Meknad Overlaadling ethod Oveaidina
Tn metnad avelaading Whesveck in me>rad ovemin q
metnoda a unchon muut methods ox hnctions murhave
have tne 5ame name and he Sume name, cnc
dierent iqncdirea. SUme 1gn.cdure
2Ttis agomple d compile whenecat is excmple od
time polyma7phism Tun time podymphisin..
3 Inhenacunce mey or mayInheontance cluays
hat be reaized eLYed
4 | iS perhoxmed betuueen t s dane between ouzent
methada Athin thnecloas.Lang dhilc doss methods

whar is the output Hne nllounç praqaom


Oukpu
eat only plantIam vegekaoian.
hreatm oxuoen

Xlercise
3AP u crecte g cass Deçesee' hawing cmethod'aeegas
ht print Toat adezseeTH bos tuosubclaasea numa
Uncdecacluate and "Postoaaducut.'eadh having amethadafe"
Nith he same mame fhak prins "I om_on lliclergradua
andTam lostoaoduaderespectaey.Coll the meihod
by creohng an object.okeach ov the three dosa
l a a s Vegaree
dek qetDecree LoelP):
orintT-got
pint(n
deqxee")
Page No.
Date

ags ndexgoraduakelse-Degzee):
del geklegree.lsell
print ( I am an Underancaducute")_
claa Paskgeraduate LDeqsee)
dek geklleqree (selk2
aint (Tum. Ca lost qaduair")
c Negaee.)
dcetDeqiee)
usUndencrraduate 0_
ugetDecreel)
pPastoraduate)
P-getDeqseel

LOutpurTI go a deomee
g m cn Undexqraducte
I am C lastqo.cu.ate,
1NA crecute cclcs tu print an intege ancd a caaracte
fn uwo menoca havin same nome nik cuerent
seauence inteqex mecharacted narcumekes
seas AO
del shouladk.c.n
paint ("Lom elass A : c n
cless BA:
de sho sel.nc
print "rom class B:",n,

oshou ("T",12

bshoua(12,T")
Page No.
Date

Otpuk: hrom das A:T12


hrom claas :12, T
2 HP n creare.adas tu aint orecs o square &reckangle
he clas has tuwo metnada uith Hhesame name bu-
itesent _oc pavometesThe method hor pyinting oreua
etanode hey 2 pcrametes ale other mefnocpint
Ce squce hcs one paYametes JNhich is gide-
_c saluare
dass Hareck
dnrint hrea sel,h=None b-None.
=Nane ond nNane
pit(" Hrec ckcectangle. b_
li Je Nane
printHrea c squcre",a+a)
obiie Area)
abjipriok real10)
abiipointLrea llo,20)

Output
Hrec c Squore:100
Horeu c1eckangle:200
Page No.
actcal No.is Date

Aim:mate a pzocKam ia ython tu demanstaçte


folloaing
Opescians Simple inheitan.ce 1Aulliple inbeatance
ILCompetencu ancl Paractical skills
lENelap enercu purpase proacmming using
Ste ianlem. non 4n
baite a rotrcam on simple inheitane
Jenelop rocram on multfiple inheitrance
IRelevont ourse Cukcomels)
Design_daasex r caNen noble.m
IMiimum heorekicC bacqaqund
aimple inneitance
he mech.aniam c Cesigning
constucincclases rom_
otne ccases is cedled inheitaMCe
The neo doss is ceuled derived clous r child cdos &
the dos hrom shich this deived dass hos been
inhemt.ed is tne base clcas or pCrent dcss
n be inhemtaince, he chlc cass acias
and coan access cl Hne
e pooperkies
dodck memnem ond anctions
deäneck in he parent class H_child clas can cubo
ovideits specihc amplementatian o the hunctians
the pcKent claa
baxe. Classl

Lemued clas

dasBaselau
Page No.
Date

+Body ot boscdoss
doss orwedCloss CBeueclosD:

# Body d deiwed doss

Example
clos Ya»ent.
pname
CNume-

de shau-plselk
i n t (selk.phame

doss Chic CYaveat


dek ahauclselk
print lselkcname)

chd =Chldl)
Chipnaume"Yiiy
chi.cname="
chd.shopl
_chd.shau-cO

bMulhpe Inheatance
Rthon ppoidesus the lexbilih o iahenmulhple bage
doses in he child doas._
Mulkple ipheaitonce meana thot oude inneitdeg he
foperty_c muligle clasex intu ne Tn case uauhaue-
Auodases 40 h ond b.and au Loant w creute
a Detwdoss hica inheis the morpenhea c mhA&B_
bost iusr like oachild innens charactenstics m
ath mafner and ¥uther,in Ython ue Con inbent
iple clouases in a inete child dcus
Page No.
Date

LPose Clasd Lasg dous2 ose Claus

D2raved Cleas
cAmple:
_cass Hdd:
del adclition (ell,o
xetuxn ctb_
clous TMul
de uhipli.cakion.lsell,a b:
ekurn_C b
dass Laixed CAdd Mu):
d Dividesel,a,b
d-Desived)
print Le.addition.ln.m)
pint (d» Mutipli.cakion Cio.20)
pint L.Douide (o,20))
KPracical Relcte.d CJuestionx
5hate the tae b inneitance-
Tahearance is an impatant ospect et obiect-aiented_
pxadigmTnheitane avides cadexesabilih to
the pocoaM_ be.cause ue cn Ude an existinq claas o
Ceatea new cass insteaLc c creaking ik eom sautch.
2 List diWereat pes cx inbemtance
inaLe inhemtaHe
iMdtiple inheikance
Page No.
Date

i Mulilexel Tahent.ante
Hhercvchica Tabeitance
Had Snheatance
A KeACiSe
aeote acoas Empouee pith data membes name,
clepartment and balomy aecde luutable methads oy
eadinq cnd miinting emplayee inmmation.
doss tmplouee
name-u

cdepantment=

dereademp (sdY
. name=inpur ("Enkex nome
sabdepootmentsinpuEntex depaakmett
Sa saloEinaud CEnter alcy
pe printemplsel):
print (mplayee Derails")
paint (Tomesek.name).
print"Department"selk.cdepartmnE)
aintsalomyseltsalaa4)
eskmploueel)
ereadempl)_
e printempl.

Oup tntes name abc


Ender depcrtmentTL
enter balecc S0000
LmploueR Dekails_
Name:obc
Page No.
Date

Depuxtme.nt T

2Ktnan progaom ugeodXpint shdent inoamcion


Aing 0cloasesuing simple inbeitane
doss shudent:
name=

deread (sel
5ekancme=input" EntenY núme:
5ele. mcukscingutEntes mcaka
closs shudinolshudent
_det printinalsell
print ( Nameselk.namel
print (mMcvsselmavka
S sudino
5.reaclO
Printinm)

Ouknu nter name Ram


Enterr Marks5
Name Ram
Moxka9S

ate c nthon pxa.qtum oiompe.me.nk_multiple


inbentance
Cass mother
mnamee

nameE
Page No.
Date

daas chilcd Lmother athes):_


Cname- )

de read Gek).
seacname=input Ente chilck ndme:"
se maame=inpatCtote mathername:")
se name =input ter irtber name
der shou sel)_
mint dt.cname.is dhilcdo selmname,
ond se.Vname)
cechld)
Cacecc )

LOuhput
Fnde namelejCsree _

temoBhe name: Premlata


Enter Yother name Sahsh
iaahree is cald c Hemleta and baish.
Page No.
ach.co o16 Date

Him- nle. a pracam in non uhondle uaes deänecd


eception nx oihyen roplem

1T Comoekency and Pracicalhills-


JeeMap enesal puDose poqaamming LAn han o
alwe prodlemThe prachica is expected u deuelap_
he mlausing skills
lite a roqaam n handle use deincc excephon
TY Kedexant Lousse Octcome
Handle ALeptionsA
yzochiccd Oukcome
Naite ciam in tuthon n bartle ue deine
OxCeption Y qVenpoblem

I Minimum Theoxehical backoOund.


Pfaon bo manybut-in eepions ahich tntes our
sooam to oukpu 0n e vdnens0meininAinIE_
A0e umoncL.BaaleMeY, SametinMEs uOu mey need ta
chee _austom _escepions hot enNes ou ampose
Aist_ common acepiona:
Zeoivisionlarat i Occus anen a nó is clivided p a0
Name trroy:Tt ocus e n nome, is not ouncx
Indentauhionalkaro7 incorect ndesmation isgiven
To01t occus vahennaur apAGT opeion_ouls,
EOFFrao: Tt ocus shen fhe encl c the le is Teached
and yet apercuiansare bang pastarmea
Ipaon, e s can deine sucn eceptiong oy cacating
a neuD ccasThis ceptian cless ngs a be deráved
Page No
Dato

eitne cirectlyox indiechiHobcephon dcass


his dea
Most o baltia ecech.or crre cko dRived hOm Ahis dos
xamde<
chel inpuk.ogelage
setintCage)>I2.
aceptValuehno?
rekum Yaluetrrayn3et inkegex vaue
ee
e n You are Adult_
xception handlingin Pyihon
L he puthan pioam cantaun SuspiciaLD Code
that
may torau ne ekepbon, we mugt place ncd codein
hey black he block must be nllotuoed uith
Ahe except students ahighContoing _a block o
thar LniL be executed iwnere is sorme code
aaple exception ndy Ha
0sint linpdEntes " )
haintlinpurl Enteb:)
_Leabj
pmtCalb=/d" 1ac)
eAept bcephion:
esei pantcan!t divide by-zeo
_int (HTom else.
block)
nter :10
Gnte b'0
Cant diide yZeo
Page No.
Data

Xarcchica related quesbona


1tcue epticn
Hn excephian 15 anemxor wnich happens c the kme a
exe.cuhion c pragaamLa khan, exceptilona iaaes
Outomtically_on enaam_ the ccinhe mnaere.cl
JO
intecept ny oun Code

4Houd o handle exceptian in than


In Lthaon, eLeptians Can bë handled ying Oay
statement The caitica opexcuianhich can saise an
eeption is peced inside ihe y cause The code Hhet
hondles Hhe eaceptians is witen in the_ecepk doksa.

ite ca puthon ogiam ta check a ZemlDivisionbzsor acepka


asint inpt (Emer a:"))
beintioput "Endez b:")D
LE a b _

ExLept Zeaolivision krsz


mint "Zeroivisionbrz ant divile vnith zeo"

Oukpu
Enkes a
Ente bi0 Zero-
Zesmlivisombzar a n t d i d e aitn
| Page No.
Date

WAP u crecde Aer dleaneçl eception tnak cill


check nethes the passudordL is_comect or not
doasnconza Poasuimc ception)-
pes
de Loshn CpuL
i t puu="abcl23
enyn e-
eei
Yise ncoxectPagswOyd
except n ç e t lassanvd
pyint Tntorectssudarc 1

pw inpur tnte pesward]


ceul- logi n Lpu)
iseut hue
int (Logaed
JU in 3sMesmuly)

Quput
Ente Peusuordicb
lncoec¥aysurdo Y

You might also like