0 ratings 0% found this document useful (0 votes) 4 views 27 pages Python Assignment 1
The document provides an overview of Python programming concepts, including string manipulation methods, list operations, and set operations. It explains various methods such as append, pop, and clear for lists, as well as union and intersection for sets. Additionally, it covers dictionaries and their key-value pairs, emphasizing the importance of understanding data types and operations in Python.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
Save Python Assignment 1 For Later
1, Basics al Pydhon Devter Showtexe. Drevieneary, Toele seb
@ Dele Me Strimy cna fig _methea,
2 SHY 1s. AL . Seqaence a Churacter
2) Striay WS aise) $0. Represented Seat.
> Sromngs cise typically. vepsesented
Jewble on tte oles.
n__ quotes _eftheh
Sy Shng is Tommmteble Jade re Le can't change
{Wo Value i ie 7
Stony — Method
i = eal
‘Sen__mehina Betas —_the_Lengt_ dang i
mek Shang veaicle. fem
ee. Sttitteteterts” 54 > "Hello Wor”
sh SeeBene), pais (Qencss)). - =Q uppeh *
> This. method... Tewsns grimy IT NPA Case
ex a>" Hella”
pont (mppeaCss)
‘pupa) “HELLO”
@. Replae
+ This. fetes 1s ised Re plowe Me Stung,
to si" Hello, wWostd””
S2> Sdareplace ("Werld”, "Uninease!).
pon (sr)
aa
Hello Univesse.”
© Tite
fuse
> This medeea as ses to Replace finer seven oi) Dowes rt
4D Nppettuse CMs semamimny leHet tae owes Cure
et Sa: "hella toon”
Sas She Men
pom. Cs2)
fore) "Velie west”so) tt appeet fc)
.
Exelon the Lok cmd is mete Git exumple
>, hsr 1S. ODder~d Collection d
> List 18 state Stone crag vetue lise tt, aes, B® -
>. List 1s Majahe deta yee. foo Change (4s Value
21 List__cam be — peslosoned t “sing Syste lowreis £ i
List method : i
© “Agpena
V_.. Appena method _ts.
| Syntes Narialle Nerme. append Ww
le C1,233,4, 2
pai CL)
2. Tonsest 1s sede maha _valte AN Aig
Syme, Listveniade. set (position, Valve)
| ise Ls [1y2,345)- ——— =
La toss (3,3)
ic A) .
pam ll Re) ages 5}@. sm
5 Sent pret ED Sweaty 6h
’ ‘
List vongbie- Sot)
Synies
ev (4: 01,256, 44,5)
4 sot O
pom(it)
Teng) Tz
® top
> Pop Aretes is vise delede cm hoe List
4, 5,658)
Dts Melon termes She fast Clement d Jet
syaex List vomoble. pop
ey Sao 01, 2,3,4,59
pla. pop)
Prim Ca)
(nee)
042,349
@. cear
>, Qead method is “Weed fo Cleat tohoke Ih
Syprm,_ListVarwable. Clewac)2
a
puhpesl
Oo
@__Demerstsare List after tok earnnp le
oO. Concer hart.
This Operation 1s se) 48 Jom Hor 88 are er ine
Gre fish —____
penis
“The penta wvepeats the sien ‘hig Ju_o i 4mbot é
4 —Fyme a
ay This qpenation corn be performed by * _egrnniets
Syne. Bt. Nemiet A lymefa {raw}
= pont (9443)
“WelloHello see) oe
niet]
Mernbesshi? -
: gives — boolew— Value Tre _ of Falke.
This opestHon
“Tf she element present wn Slit Th gives. Fave
Te ee tr TL. :
omestorse Fae Paes
eam i
{ier _enet_in__ Lis vesiable_
2,5,4) _
_pint is. 5 in Li
“ewe (CF met ts)
e oe
Shims sib Nie son the. sna
Syne
Varah Ne > List [orat, step, Step]eo rs
B 0,3,54 oO
pains ater ‘aie
0 Callecion dane,
oi Me Ls, “Type ygle_1s terme
is valve
+ see —xi—att Iaet O—_—
~ eons supe =O)
my Fraple Carn Comin — “Clement 1m _diflerent_daiu ypetai Pang nl
feet, O78
pekens tothe —-prntes d_ ed learns
such as tuple o% list
e
“ahd omnes the. fou ele
sete, ut Oy
ss um _1ndes_of0.
The send _elemenr _husecn msl 4am) Son
ing. tuple> Coe PC) =r
pain (my. haple Lo)
pore (my_tygle £49.
(Comper oeeeSeeeees
<
Cy
b
A Negerve Indenrny
D Negative Tnaesing Stes Cr = t Which omens
Jost elemens non tuple has a thoes a
> The semi Qu element hase tndex_o =2 erst
So. om.
ex. aees Het
Mg tuple = CPO)
pom Cony tuple 39) a
Pom Coy type D5]
@)
4
poe© Dermom sree. Hiple opeshon, Colth exam ele,
© Comcokenaion (4) _
d- “This, opeation, Loca “the Selme cs Gin
y “this _opesuie typ) —— _ - - _ _
bugles | (153,5,9)
722 _duple 44 tuple 2
prim C43)
[oveur) Co2,456, 153, 5,9)
—— —
-This__ofesateh__is_used_4e__epecid the tuple cw.
tL. oe pe
ane ———
2 (12,3)
ote Ge) ————Mernbes shi?
Present im 4,
5 ue. 5
- soph checks the 7 ee
> Ths aeeet as presen fren He Chan Ty,
on 1s
Gimescose Fubse
5 ths opewiion con be dome by — asm Im Mot on
) "s i
ope sitet
prvont Clo? ve 12)
poms CPt th)
“Trve
False
B®) Demonstocre Faple Built ie Cancion. amd Methed wen
example
Taples ate Temmrible Se Het Tale dees herve Tesi
cto ci) o8 temove — Fkans. 7
© como ioe
> Comm OO Preded is aused te Come _ at OCCrrane ©
Partials value.
7 Z ;
sched mone Ie Lee
pet Loma thon Beto.
Syme
Very rabl
diable Name = chaplemmme . Cont (Term)e& dds Co 20, 4.40 50)
Hote)= Ay. Corn’ C39’)
PAM Coray)
(oun)
(a) Jndex(0 Linen.
H
> Inder Keaton WS Msed jo
ST acum s Mac hos Position. _
Sb ow Hae fon
et “Pardiovon vale,
Ahern hrm con CA80R
Se)
= ple. Jimdes_ Cs)
— pont Cimdes’d
® Leno Caen, — — i i
: ~eeion is as@ kind he tose) lng
___ewonlenble jn aw ple: ta: C1,253,45)
pant (fea Cla))
pu ut
§
® Teylea
> Ayko Lciion 16 8 0 Coetle ern erp ty Tuple ff
Me argent is passed
D Tf we pass Sequence Ye. arvevament J pe, i
Comvenis to rm jrmmnetable tuple,
Symes
Vaviable Name = tuple Cseqrence))
Bx tae tuple (" Py wn")
poiad (439
tre _ type (02.39)
po (ay
Cerin oer ty)
€152,%). oe
@.-winer_Limor(a_[ swt)
ee
Smad Aman 15 asd ao mg Taher Nomex of ple
> Sw) cher 15 ase) 40 pa co zm Mean a pleSyne min Ctupie)
mar (tuple)
Symp (Huge)
fe ta: Cs,2,3,4,5, 6
porn (emi Cay)
Pamt(orax C4s)y)
pom Cour (44)
do
55
G) Sovea Sa
>| Sovied © Leveson “is.
_cigcen ding — disk onde,
) tt semes tuple chogsment edb
Sovted Noimbea
Symone Se Cpl) ———
cx dae (2,8, 8,132)
prima Csoates C+1))_cote Couple
©). Fxplan.. New! Tw
3A Tle is garment rioie. — crm gle fs cats
Noas Tye
Ym other woenas ch tuple Com hall Cine thet typ ie
os ome tg Clement.
Spore
Traple Nome = (ems, (taple))
ex
Sam = (4,27, (los, "Harsh", 95), (le), “Om”, 4)
pont (seem C23 £49)
(ouge)
“Hash?
D_ OMlrece erates Tyke oma lish,
Tae raclis
Of ea hese © Lists ore omalle..
6 Ve Coname he i :
SS Memep ‘
SS (emposer to iy. : Congres rane
Oo a
=i on Os aseysl @ ceae base
W® represena lish
|—— = |
© pw. aple -crarme ~ (3.48 |
©. Debroe Sth orn} haig 3
Is fy
Coens
> “Sets snore), “ Olieesivn. tions
Clement: ig
Mi Que,
Mstable Yayo). type
NS Creclge) Win Cy bnackex 4,
Rl Ahese_ Is o ‘ped (ening — a i
i) —1teng Symbol, 7 - 7
— Omg presto bssjecling Lt
8. og St
> Sehas - petcovined ee sng
te sag. S12,
®) Using hectsioa =
?
ne Se Se Tb
Do We Com tariye Sot vusiny
ee, seas Set (C,2,3,4,52) — a
faim (se4a)—Jierns m Sete
sa =.
QD paplam cece
tree) “wimexed Se we
1S
Sep im Pephore tym etm it WE Cory
94 Sein. He Tem aly
os the Spee _
Com4 cxtess
cccess al! the Tens. Fegethes
endese), 2 CATE SC Slreieu,
ae ene renindexe? , fl 4
7. SI a. gn 504, 74 Gil) give“ Tye hon
on inkexy , :
When stsing. Imexing
ex. arm: (12, 22,30, 40, 50)
aint (mim)
point (mam 03)
(Grips] Clo, 12,3 6,40, 56)
*/, CALAN
@ Dermensta Set operation. ime Py than
QD Anion.
dU
lem opesation peskrmes union of toe Seas.
tohich Comtums all the Elements thet cage Prt en
1m both the seat pict
Syntex seta. rime. (se42) nec ai
Seri sera.
ee m2 X12, 44
Ne C3,4,54
Primt (my. sunion(nz))
(Sr)
Su24asy= 7
| @ Inter Secor
2 Tnies section __ opesceton
c Comturrinny 5
element Tem bet can
(eae Cee
Yesente _opesution BETIS cy Se} Consuming et pee
tml4 esis im Set d. ond pet in see
Syne Set 4. Pelee Ce) ee ee
SA =
ex __ S42 f1,2,34@ Wipe hao te eid, Fewer. cn. clement Tas oneh
~® Mee +e ch) rm Whe
o
arg A med
D viwg ephend? Mmemed
6!
>
Uierg a0) meted.
Ye com aa oe CRmenb We a Rb img ae
“an? meted,
ea. mye sees 1,2, 3,44
mg. ser .craa (6)
fen Comye se4))
bier) f.3.4,54
D vw yee meter
5 ‘
Net Com phrase Lah rete clement. ir
whe ‘phate 0) Medea.
= emer anes an Tematle Csi ox fut oh
fen Sek). cena cuaas th element 20 Ane set
ho mysers § 4,235
i Toes Ftd
dp hate. = Clement
Pont (my. set) tio : >
; Gear} Us CY@ How +e temeve tp Seb.
24 heres mae ee eee ou oL
a Mai, Amen eeths
OH dis cont metres
QD. Meierg. temnes meine
Yo Met cen. semeve — element —tern
| terme Centos.
et. My sed: oo sy
fr—
t [Link]. siemave (5)
i pains toed ee
| ems) tise, iy
4 Using . i LE Has
a 2.,s. “preted _emenes.orn_flemenr
4 Sta doen ret alse Parra 7a Clemen}
; . iy sen eal S
puma Crrynsea)
pas) tas 4rn
Sscenertg. coals -RAn FEISS Crete
a :
G) Explin vibe is
In Patron’? ;
> Dieters, 18 maneridese) Collectiom ot Keys
cheney .
pcas.
moat be
ficerssy 8 INPE~
> Bahk Key im
5 A Aitinsny 1s rvble deta typ 1G WEL Gg,
Fhe vane of dictomeny. :
A Mya te cree dichmoly
4
DA dictinrry is Geka sig Gly breeres
ond each Key 6% we Puk 1s Sept! — Ly
Colons (:)
Qumydek 2 Sa! ape, 22 lena 32" cut” y
D Mow com alte create om Cmpty dichonury
co. my. dct ER QU bow
(® What is means by Key - Valve patr_ fn dictions
>. Te Sctornny 5 Key Vate pars ee te Lenker
Clemens iseh te Sere ond thrive Jee.
‘ Key valve flit is set be Tins
7 Memes a Key Tenity a -umgue _ elem’
mM dictionny ome Comespordry value. batt
NS Assured Coith the KeyVy Ter con catuns the vate of key im dictlensey +
“ising the | Spake nut ke C9 cend Parsing The key ere
Gn agement .
eo MYe Heh LL Hotehnn! 22" Dtyyesh, 32 Dee
prin Cmca £49) :
Primm Cy cr (23)
print Cmye diet £39)
(ores \ Kew shoe
Divyeth
Dur
fi 0) Laplam — Dicttensny Gay in levied orn) Me thad,
© se delavt O
aI ‘sel deka ©. mttd is Sime 9d) br adds key
Nalte — Pav, te 0 Definer y iE te SS met i
Htonasy
Syrmiere deka Setadiers— (Hey, vabse)
Oc Shaent> Sas" Kosh, 2° * Divyeth 83rd
Student, seb defeat C12" keh)
print (stunt)
prtinat) 00) +k 25 Dye", 3 "Oa, Ae Koch
A. top 0 ul i
> AYO. meth removes — the tems ‘ome dicnuny ot
Which — the Key 1s Alves. ‘Lt also tehomcthe Valve of
athe pope? er -peer tiche fog (REY)
: ied veomnes all he ‘yeome Gum O detinuns
Clea) eee
on Te
gyno duce CeO)
So
fh. Bi fenicd= LAL Raven?) 2% Kali 35° Paungs |
amy be . CeoRO
Grint (my. id)
ae
oy
Bante ie Grose -
Sent)
t
A
ta) tapchen “Heroens the Jeg nm beh f
Keys value pains of the dichonumy passe) ag ong
Sues Lent act)
CL Statens SQ 12 Rom" U"Hemshma”, 92! Kalk
sat: Len (stent)
promt (size)
Para] 4 |(©) key
3. Mysto deaiton. itr oO Sie hag on diesionens,
Synttoe dies keys
C9. Gunn D1 8" ham”
Keys Newel Auden) vey
Porn C keycy
BL CEs ,22,65)
love
OD. Heat
J fits 6 Genet otha o Sixt ntuple (Hep: vatee) gag
| Syne. 4
dic. fern ee
esx.
Stiyent 2 D7 "arm Gs" erishs.” ya Ke Ki,
new = Silden} farm) Verms OQ
point (new) —— et a
(Pner) dia. swens (LC 3 Reema?) , C6," Heuthn) ls
Lh ae
@ White down the popes of Hirtmay
Do ete ane seme. Prepeaties At eee :
ro} Unlike List, — Dictionary as “uneasy
08 dhe Hem 5 sree diHonnety, :
©, Dichoway 15 Aah Lahich. mews we _ Com ext
| delete cng ple 4s ae anbe onmqen
Jn dclionnhy cst 5 mye,
Cay) Back Key
dictoreny res be lammttble, thie, ,,
D keys in
hey cant be Change?
© Th valve ol Jictiewmty CO be me Inching
cy Tuplty Sting
other dryer types ice Lisky “Tule, Shing
© Vou ctm cess fans in diCtionsvsy auciny “thes
Key.
CD Dicionny — cern be
DA Jicttonuty
Copied Min Copy OO. Method
Com shay Ce,
Vie ch Pagtam fo inp Tonnes ol H Crmpleyee
cent Stove -fhem mm type. Ago mpsh & Mme Fre
pre ¥en cmd fymd if Aris Complejees Present ima,
tuple om m4.
Yd ome vane (impr Enies the Terme A empleyee 2)
Com plagees = ae (impr (1 Enter the nme of Camp eset
Lay.) dor 1 im tmge (m))
Search -awme > imptt (" Gate amume do Fath."
HP Seer Teme fa Comployees.*
ot LE (4 Qseench. mumey is cn eomphycec)
print (1 search mame Y is w+ am emmplyee’)Loven)
al
{Sirgen s fy A A
Fates Abe “alan ol CmpPloyen
Fines the Name of canployedt Meatslenae
Eniey Me Nerme af ceanp layer’: feerrn
of complyees. Bali
Enter the Navre
P
Eres ‘by ome 40 Seunch fes Preven
Wr cm employee
Ranvun 16
Cheap ce Sichtonmay With the bol) Nrenbeh, Gane Cd
1 Ontos M Student — im Class ond duper
ne owrmes of Siudend— Lohe have Scored treorerts
Above Fo
N= tnd Cmpus (" Enea Kms A Svea,
fost ion swunge ()5
om bea = ienpvtt
ork 62 int (input (4 Enis the crmpenben ef_spadere Sins)
‘nurme? + 81me, “crnucrks? Smrecnes Y
sSdudens [aol nvmbeaD)
paint (1 shidend whe Sted above
f el) Mumnben, jarfo__in Student. litms {+
et >
Vf and Lio] > 962 c
pot (Cmfo Pnume’]) —©)
ee)
i .
Eaves te amber ot gradent £2
the Ofl|_rem be é Student 143
Set eme cf Shadend dt Kish
the murs of Skvem 1. FB
bm
Fnier jhe ol minh oh Saude 22 Ga
Eres the crume of Stuer 2 Ram
Brith the masks of Shum} 2. Bo
Siidenk Whe Stored above He trunks."
Koishe
Run
Wie a Poesia to input ou smile, tom the “965
Gms Spe these eTtmben jm a tuple — Pam4 the
usr am) tama Neonbey this typ le.
ons inh (yapa (" Eity—_tae_avrmben__ of _Nembs 9)
spemits = Augle Cine Conga (f° Gries Nomen C0142) fj
in tange (m)) oa.
Max _ arb = pax (mombes) =
Min. rmbt = 11m Cnamier)
rim U “The — puximym mymbet_is Lomax cnimiens’)
paint (0 "The imtmsan amimbec is {prin anvmben Jaie
_ Tntes
Boies
» Fate Werntes 2114
(Ean Narmben 41S
po
(The Muninmern Nob \s 45.
The Minin — Noes ig 23.0