You are on page 1of 10

HsszGNMENT 02

sltod, Explai huw fo Unuate one trovenoe a 1t


e ramo le.

A L's ondud
in
Pyhon h valuwo oid he IsAO con
con be
be
n y ype om
7he elenmrods
anr Callro a tlimtnts on items.
KS av
entloo10 w9hin Squtrru brotkes.
Er mpe
Is [3,
fon tem n s :
Co,], -s]j
prin im)
3H

Hel lo
s

aDisuuoD vaniouo wnio with example


) Ppprnd()- Ths muho o ord lo ad a nnw cmn
aht end o a list

FxIs[; 0, 3
s.
oppmd ('hi ') /p[, , 3, h:, o]
.appnd (1o)
pnin l1)
Exrdl) Th.s muhod aO o

he tbmnis th's s an adolu


vokih) ltt.

Ex

ISa Cs, 63
lsa frrtnd (1s1))
pnIsa)
ep=l S,6, ', , 3J
ho uvrrve h 9iven Ur
) Rrvense[) ; Ths mhod con
b wwed

Ex
ls [ , 3, 1, 6]
As,9tVense l )
prihi (l)
le:6,1, 3,47
iv)Coun) i This mthor otovorol to loun numbo
apartiun vedtrt. wilhin l'
Sx
ls[t,3,S, 6, 1, 3,,
ls ,tont(a)
o/p:3
pnh(is)

By afaud, he
Jntibn twr Dn hitms n

ls [3, 10, 5, 16, -2)


Ac. SondC)
pu|lr

(3, 3,5, 10, 6


vi) lan f) !- This muhoc umv alhe eumn i h lot onc
mak e hr lsi tmply
Fx r ,2,3)
s . chont)
prin(1s)

vit) Tnount () or o vlt brtene o tinolx o ol


th lisA
Ex ls =[3, s, 10]
ls. inbent{1, 'V:)
pnint (is)
L3, 'hi5, o)
Vii) TnlerC); Thts mthoo eFo gu he indi popiHhn Dl a
h vatut to he list.
FExx A c L , 10, 5, 3,
ts.thn/a)
(
how rtdt a teple o n no venoe
lhas io tuple ,
ph
yoie The
he
Aye ir o Stqoente thhms sumilarn ho lisis.
d hey
Valus o n e h e eplt con
be
of ony yo
tuong innguro, Va U'ke Uls to hpplts
on
ane 'nole b t
mmwalt. Ta l o , va/hio wilhn hplp tonnot be mucleo

Tp leo an
plto tompambk ond hoohob/e vbinto, hnu, thy ton
drtionaneo.
be mode a y s 'h

Fnuits ("pplt", boneno "chvrmy")


on r i Fnw'ts

pnintlx
lp opplt
bonvna
chenny
Dsuoo vavouo trpt fontu'o wih exomple

Bi) Empiy hptl) An Empy Con b Cuate vhen


Lang a pandhoo on ohg auno plel).

ype l11)
riaoo wyph'>
i) Lomponing Tplto[ )
7plto con be tompared o'ny
pnaer ik >< >= The om
par'sen haons
Itxitognephically
(1,2,3) =
(, )
False
(3, u) (3,)
TL
) Tplt wong si7ng ) onvenoio
klng in o a
hple
t Np'h ["Hele )
Pintlt)
ent) o b'nedogth e ple
Fr
t C, , 3, 4, 5
prin (n lt))

manc) uord o n he mwlmvm valu


valw in he huyole

' , 3, , ]
print lmar(t))

vi) minl)! ord o nd ht m'n'mvm valv nh hope

t 4,
pnn lmin (t))

Whas io DrUionany, Explaln how o tuase cno rovns


a List
A icAonany tolhvib eun onaened o oj
key 'valve poino, wih h nuunumini hes kryo ar

enipw n cuionany. h vcdoto 'ntliWonany au


ae tore uoi'ng keyo.
Ex
7om' 349 'Juny: 813S, 'Duncd d H93
on , y in d.ihas():
prht , y)
ofp Tom 3491

'Jmy &13 S
G Discus unio o Diuionany
Chant); , - Rimpvto al h thmmo fum
rom he u nay

Er tn bnon " Fon mvch1" "u ong" "Yton ";198 +


Ctun. t/tanl)

pni (can)
i) gv) Run h valu h

Er an "bnord": Fond "md ": muohon "ran":1964


rCangt [ "mvoel")
printlx)
i) popih) mve Hhe laot e m hum he
ov''o nany
Con "brond Font 'mod ": "Mwong, "yran": 198H
C pop'hm()
pnh+ lan)
)Updo ) Tnovn on
aliuonny
Ex
Con " bnnd " 'snd" "mot!': "'muo eng"
"yean':196h
Con. vpdat ( {"o lon";"whie"})
pnltan)
v ihm s):RUunn he
dithonanys key valtu pi'no

Con "bnon"! Fond "muok": mw bn9 " yean: 96Hy


x Con iemst)
pnint (x)

vi tys O Ruwn o
dn tonlanhg he
ce cAvnay's kry
Can brone"; fend" 'mu" mon "rean 196u
( . ceys()

Painlx)
Yii) Valws) Rwnn o is of al he alvo i the elchvrony
Ex ln "bond': Fono mode? mO long
Ven 6
an. vahusl)
Prndlx)
nuguwan pniooib, plat me nu uguh
Ppnw0fo etnuo
with Dunble hompe.
hncto woing ugulan C p nio

onc erhno t y only


Stanhmgon
he lino Juwondo
on uauunuo aHvns

math ing Pat vnn lo


he VUy
lommon eaok solving pnobms PrOgom mattoly
twe ho ve
bove clone Such tasko Suth holes eanb'er oing
Shnn slPu
SYnng md strng muhods Li'tee p o l 1 , h d )ee.
As he aok
o Starn hin9 ano extpovng io veny co
Pyhun Pwvido a Powenpl Librany Callto uguwsn
expnooionD to hondle heoe aoko
hove elogon vly. Thovgh hey
gui'te
o wmpitarc Syrar thy pnovtoe eh'irot way
Stanching Hhe
pat ns.
Th ug uler erpridnr
pnognoms o hemse) ve
Sranch ond angt ointms To uot htm in n ow
prognom, hi
libnary /motwle ne
ne bt mrontec,
Exompe
impmt ne
hond optn'myfilt. t*t')
hon tine n hono
bbe Uhe.
c
nshnpl)
n Stanth [ 'how', lne):
pri Li)
op helo, hav
you ? ant
how abouus you P

claso ,Explarh how fo


Depht bvat
vbr
with e mph
Clao clruc bluprint on
pUtotyp
Pom whib vbjrcs a u tnvetr c1asoi p0vcle mOns
dato and fwnttionalhy
bunding gten. Ouutitng a
a ntw ype tw
claso Chuae of obsrc, allqv 99
b e mad.
thas hyp
(4

Erompe
Claaempoyt :
tmp- ount op

ode- ini_- /sef, emprome, salany):


Se'.Dome emp. nome
Se. Sal
Salany
Cmp tont ++
d cttspoy (org):
pnint ( tmp. nome slony)
prinll tplcyee, tmp- tovnt)
emp emplayee[ "monish" ,o00)

Pnognoms
oll valu iin
PP o vate Ust and prn
wnite a a

u verDe ondun.

Ls 10, o, -3 H5, 23
printIs:-1])
wne a pythen pnogrt hut ako two ls/s md neturns
hove krao
Tru
Tru i huy a Commen
nmer

de tomnmon 1s1 tsa)


Pog Faloe
Foni Asi:
o n j in lsa:

oy1nue
bruak
utunnog
a l 1 , s, 4, 1SJ
b: C1o, 6, 7, 9 J
prnt( commnla,b) prinis ut
wnle python prvGn0m to nm0ve duplitato rom
Ust

dRemove fis)
unigurls=( ]
fon num in s:
n m not in uniqptls :

uniguels appd [num)


neunn uniqve 1S

ls l2 4, 10, 30, S, , a, 4J
pnint(Rtmove /11))
o chruk a L s s emp
twrvrt Pylho nognom

D not

isEmply (Is)

htunn Tnve
else
nvunn Faloe

pint(is mp'y ft 1))


pn'nt (t Empy (l 7, 1e,u7))
al ihe Put
Lnile Pyhen

intirto tmos

prht (isl: I )
vi
VLwn'h pyhon pnono otnpu a b'ne of t r t
Cwond
home
nome he ruopunty o
tototh
h
ondnd

S: inpu 'Enko
o niny )

Ch in sspli():
fon
o.9tlch, o)+1
dch J
pnin (d1)
o dyoloy valuu and kry G
vit) lwnie o Pyho Proyr0m

d'u oany wony ahuplt

tel-t'n 1 Torn' : 3491, Tony': 8135, itkry':/2 S3}


n el- ctin. Phm l);
kon eey, val
pnint lkey, val)

vii) tnile o pnognom


ltens nd
shosd Sar wh only uppn tuot
he ing
Cno muo anluna Sotcia
should tno wh c w'g
0 n y h n ti n btturen
Chanben A

impont ne
nomt")
nomt iopps l Enwr plt
tny:
/hond pilfnome)
erttpl
connot be opnid")
prinl
ert Co)
fon int fhond

pat'A[a-]. +\^. +[o-]$


Ane Lh.nSnip [)
ne.fihdatl ( n lne)

l n Cx) >0:
pnint(D_
PyPy hon pnoynom ha mathv shnn9
os hat ba tn

a followtd by onyhng. tnding n 6

impont ne
S
inpu ("'or a stning")
*
nt.pindal"'a, +b$' S)
Prind lx)

You might also like