Unit <1 o
Prrwoducion —to PV S- Puthon 30 ener) Jpunpase. i
a igh taal” and iS pheied aap
oat saupposts ged Onented a0.
taalin “approach +o develop Applications. P+ V Jo ov ple
ond ae \eann and provides Jobs + diy Sod dole,
S™Madueed
Python oan Imented Guido Van Rossum in
199) oF “Cuot CCenten Me atics and Compule Scienee)
In Nehenland . he iden Oly Patron Leos “taken Poor
AVC proghorming Dlenpaainte
= he came, “Patron ‘ww ‘choosen — Guido Van Rossars
Wan a
tne populan Bac
shoud Anak ime “Monty PAtnods Plging Gruso” “Se
Ne decided “to pick “he. “fame Fanon.
, oe
Pecmizeo_ oF _Putvon, %
2 Ne yee a Ta
a
Jorqsog dae ren - Jeol data Shuchre. that “secluces.
ane. “Paamecsork “dewlopment dime “treat toa ence. requined
Like Pytnon is Daanirg List Coreriradte.
Aidionanies 4 Shashtntes to Ste hes Agha.
>
Ob\er Ovrenred - “Paton San abet Oriented P .
becouse. \bt oer ie, More, er'"d
20%. saatinen Ahan alepiithm, Norco Ayton bo not
Obie” Smened bub also a Jpropen combinahion
saultipe. Trason'y Poredigm . Sike “bya, Use Aas
ook . °—|
©
oe ee
Scatoste Sihe slenm Seatotoitity sidges He “Yn— “a0
ob she +o aceepl ar
horde. Ane. oxienald mrmarce reaquiad, LPO
Ane addition eo he fies ate ae
Petron doo a) “pgp 7 modulon
Extensioie As. he amour oh Raren oT cally Sa in
OO) “poled ose con exons ik
ceparay code. into es bieo ad ™ wo and
be alo\eS acre cade, dyer one medule and
otoutes “ror ancthen.
e
Pyros ows She PERETTI eo code Some
part “tre Jprogzam in dibbprent Mike Ct jJoug
and utilite “then “inppagl paren cate ,
Pore i \i Zine. B AS writen In C 43+ con Worn
et Baifoems re: ine es applicahion,
bat on One can sw on halla wilh
strat me
We w No wm fe Wel parts
ANST C compila. eapponts “Patron.
Easy Leann Patron ns, one aa de?
BimpPe Sphe anda a
Ano made VW S054 7718 Seon, Asmat “a
Easy to mead Ontike ener \b doesnot
crake Yor of Sypincls ine a) ee ae Vaniables,
deigini cde Mala and item: math Rather
ddgine Sipe and dean code aahidVis easign tei.
wammey to sed
Pearls. Roousr ‘Patron Pool i
qo cell ‘a “andl er tong ane
Diandlew «Pyron S By extepion Drondler
{ng ~ Pwocero AN Plgyi
“We prodblen , aedivect Wa PS joo mk
Ane application San Wy ow “ys eer ¥.
BR Merosy taragen One of the main adiion
: “9 a) Pyren eps Yon “62
¥ edly Suondles alt “the. \gindtoncbittes Adtated >
MEMO, ey ond Gecausa_ gh Arak WH KAN
e cedices AWe cura! Aexlopment “ima and }
> | Anvenguaed and Byte Compiied ba Patron is
) wet pled
A
an Winged as wary
Derg , BT allows the. msMeN TH Bw Ae
progres dive: sor he Code. Withoal-
payer’ “tne completion preceo . Hine pastor
\prowed ore Petnen aS
+ De pst “RansBrna the Bounce. code. Ito byfe cade
2 ren We ansile Dane. code Wao Ne cade.
- othen Dun ihe’
Ane Aproegammen peed nok Aros abou Ha
Prego Camnpichon > Aioeeg ond Lady A Qiomies.Paton Resics a= |
O} Syprex Rytren io a Men Roatorad Jongpoge. and
woe. most oo. arslapment: ‘Shalemenr.
Dome = Expreoi on
Here Ke come do inded do She value f, the
ExPrroion Here name do ot ond “ panhullon
acta ype ond $e TA oreeiay ssinged :
ee cae Qetoo FE an int avcignment e
b=\c0o-0 tea Poin
cs Tren” 4+ o on
~ | Werke Pytron delgnes an iaentfen sing Mdtens,
F- aNd a ordensesse Jot Ino Bar
Cronin arould nee bo Siaih- Ane Aibdnect—
possivle. aly 09 WentiRer~ is 4S . Bis
o cone Sanctie eWene one 32 cenado spytren
and jas, break, clove, “cortinse del, eke.
- [Rules and Saptlo used with Selemens in @
Patiren : Srolemen'h nced
HRuow suleo and polo SH a -
\ Comments YA, Color
Q: Rowden Ss: Sricsten
a Waning G: Sadentaion,
« Comments &- ste mbol is Used to Crete
any dine an “Comment Qing. on
gloco nok char a aCe fer math’ Lins’ Comments
« Yodube A module allo us 4o \ ;
oan code. Wodsie is : aye Prin
otegygneo LY Osen ddlgined mmodude_ BTS Bailt in emo gureSe
© In Ryfren Weddle Lo 0 jge Containing, Q Soe of, fanchens
ron slo include IN Ypan applicatén . oy = "Worf
Tew te wa mrp
wnpcw— nt
mn 1 CY Word” D
row te une Shuih-in Node pacers Pe addyrad)
wo \mgori- prot foom
K = Veron - SyemO pe
aN tn will or id) OS
Pe gl ln bin Orca
Linux.
impos platform
Re cbr Cplat born)
panko” te clifferesr bxebreo
* Nowlin — Neolin brace oS patton Statement
inte multige Dine. Are Nash CN) to
ned %. denoke nesobire:
ee fy 18(Comdestage 7 ID and \
Candenrenrn'7 3:5)
admission =!
crowesen Sines Con be Cortimed on det Lina ihab
hae NG ]extepr, in ARO Cares
cee 13 When endting OPHWD one used sah oo
Saponre bral OF Fonanthesis .
i
Drow Aw cawle_ wsen ddgned mail oe TC Maa)
D a A Com). { movpy Pe () Ho
paar Ci Selo") Q
def Ft Gone)
“Prnk CO" Hedo + one
Cone Xo Wen Aripe. Qpioke One duond Re Shinge|
é at
aro ~ Se pyres a Se Oy Twiduel Siaremen
Ks ane Known
“thst Roms a Single code vod
SS Giteo, Complex ard Cornpound Gtatemens Si
ao WR write, Bo rede a asle ard a Meader
Ore B Meader Dine Stats Gy a Heyuad aod
emp wilh a Colon and tnen Piloweck al ong, Oe
mee Maras.
*Semicolon — Nultiic, Stelemens. ane allowed In a
ach
Sire ire vy re Semicolen .
oo Fae
. nn ,
\mpost dec, pa Yeten's
+ Badentation- Go Python Indentation to Woe te delimit
plod Ay code AW Linco be Progam mist be!
{ndented tre Same Number oh Spaces.
Vai ate Masignnenl: So Vosiele anoignmenk can
be. done. ho, arcignment operator, and |
ongrentd roigarent often. Ola. es papery
Serquoge- Anis openator Adeonot explicitly aroi nda q
Vole “to a Variable. . Sn Anis Sarguage oj anell
seFenenced ,
ert area do dhe wae of, the
. ented vol
Oe en 4, axithmelic. opemby and aveignrmant
open ge Salt
Br gt Tal
ite]oy python anultiple anoignrrant melyea “to dhe Ana
4, Single objed ‘to multiple Variables.
hae ® Heyer eS O@ x yx =F Ix
“Print x) Prot 2%
Paar wy) Punk d
Print Cz) Pr
*
Hatrupie- aveigereont-
° re a i, Tate
Dynamic Qye\ ~ Ane “type and memory Space.
d 4 an obied- in Python Ane ey
and altocoted, at sin tneche pe tthe objec ds
Aided he volue “that is at Sight wide In
easignmen Solemenh .
- Heong altecohion - Memory allecation and deallocahon a,
vostableS Will ba. akan’ cone ne Tao ib
DB] iw rengdren , |
+ ReRenence Cosnting — 9 95 dood tbo Keep toad ol,
obiedds in® memory Sn intenral Voniable_ |
oeyrene count 001 Keep “Vead< al tha. sre erercen
aden objec. TIS iS called saeco,
| A aebererce will be. mide. do an cbied
gone it is ceokd and a © com will be “ZL,
ashen this objedk is nok meedec| he aefeount
© and iF IS a collected . afhe. coun irtaemen hs
when allaces are caakol Br ths bed Ae oH
ee is searoigneal wih, Goma offen value.Soa
Grstoage Collection — 8 ub a mechaniam “hab io
po Salnimina es memes hat do nok used
SAME Oh cheda [Sr objeds tal Las ayn
C&M ad Tero and) then Nocoleo dememony:
Hew vantables one. deleled in Pi Br a dona
i ao ad ‘tayoood
Be x
: Pant a:
aaa stele ia rob debjreal “|
Si this will b2—
printed shor lao} pin
Staleronh.
SPS sy cocale. and aun Rython Scxipts 2a
Spt. Roe Sado aro Frat py ah Commanch Prompk fo
OPM sano “ext edits
Step Q2- Creole. a nao Re.
Sep B%- Ape ANE cade,
Re Eq\e- HD
& a= 6
San eK
Paar Sor
Bre hy- Saw he Re
Sxes - Yo sw He. Sew} Ayer,
+[Rsbsp
at Command Prompk.“Python Oviers ah pytren objec mede) absbaction
Jo, awed ype Ine -punpase of dla shorge,
=1Nis maid Stoleo “Hho amsbud- rok hots a
Velue. will be Vested a7 an ced . AN objed—
is 5 B aiPRenen- -—Vohno.
+ Warten 1 An idenhien uni ientiRes an
orjed" - W Iw dtonnmied by sing, ao.
: Be a pe @hoas Wwe Kind value. an object
e can seve» Kink 4 openchion that can be
an Ane objer and Ane bekaviosy oy an Objed- |
+ Volue 1 Sb Aenoko ne sta
Seproend by on obec ,
A thee 3 -Rohnes identifier ancl
Wee atibubes
ane seal only while, Value Ip Darke only.
Hem whith is
Psion Dota Teco _and Built-in Apes Voniadieg
econ hold values and ony Volue.
pon a dato Pe. Pyten is 9 Ram ped
INE the-
waniabie. We Sedony he. athe woah. ieBholy
indo ane wwlue ooitr ils “ype.
Br 8 ass
tne the vanable a olde an In value. ord ee.
Drove. 90r alehina. Tks tye ; Python interpreter will
qubo moh interpre Vaniable 9 ae 90 inkepen ype.
thon provtes 00 te Hypel) inchin cahich elma dhe,
ype of, variable ~ pamedl,Ndbss
REE aslo
b="HiY ole ink
@="lo.26) ) Stree
int C hype Ca) Plow)
ea ch)
priok Hyped)
Pytren provides Vaniouc Stanclard clok ae tra—
pyres Ihe. selemage. mead on each of ‘rem
NOBSS -
Numenic
Complex Nurben, °
Plog
“Dichorany
Python Daly
Types Boolean
Sq.
‘Shi
Sequence. %
al Us)
Numbers Fe f
Namenie 4- Number » Gwxs Mamenic, oalne 8S
Ane ‘wiegen, Rost ond complex y Salis to
a geen Pumbens dca type.
ink 1 Shs dota, type aon ae) Weg walires of
oy:
Rock %— Anis dato 30 ved to Jad Aesing
: Point number . preaioion i+ will Lol!
vp 6 deoinal poink.Eo
J
* Complex — SWnis dda ‘ype. Comoins an ordered
Complex number ie X+i wonne x
palo
Ord Yo deol “the Steck ord i imaniranay panks .
Sa e- @ Is an Lnordencd Se of volue.
spole aA, tema 2s anes 8 ae
WLE Lene. Cad Stoxo a Speaie. value .
0 con chold ony Primitive. chia toheneao velye
wo an stays objec. ‘A[he ikems in ro
Jeol co'h. mma and ercloseol
in beates.
ae Gi deft. Red! 2; "Blue ®, 3: Crreen'y
ine(d)
ink" IS color ttt +d(11)
snk CDE cots is” +02)
Ca. Hays)
yin
ie pi Cd: valueo))
olp :-
@ $12 'Red', 2: 'Bue?, 3: 'Gaeen'}
@) Bt color is Red .
@® oe color is Blue,
@ [oP Bnd
> Red Blue een,
Boolean $- Baclean Prevideo “two bujlt~in
values “Tue and Polse « 9) denoko by clon Boo!
Tite con be sepxcenkd an fem—Zeno on’ J)
| ePrewao be con te ed by O oP?Se 4
A es |
Br iS an OMosdenecdl caltecrion of, the. dake yt
SNS con aloo <2tale. an ee
Rs ac a=) S80) HE emey se
b= kL" Helo’, 2,314
® pam C6)
. ads Clo) FF 989, 99 emen)
ine ©)
e Nib CQ>, FF remo. 9 clemenh
@G) Past Cd)
Ser connsl~ e
we are a Soe, eS
© Hello 2 ai to
occunene= sy HE
Some, hemat
@ ello 2 3)
Sequence Wee so gone
rer
Fe: Shing , Usk) Tape Of, b afRenerk alate
+ Sai
= o\nis Asta type con Mer ae
“ne Keyprora ao, Claned
oe, si Con m deel
cite apne op Seale aepoml in
qpotation rank, 4m
Foetal Stole,
aloubie. oF ‘hiple gyoteo “fo dei a 9
sb
Dh coor of os Aorelli aoe a
oy ) sured fo concaknale +50 Shings
ae Re Si “hello” +" wore!”
- arehims hellowor.lol
ee "G by * is Kroon ae aicpeltion opoaby
— “Python! #2 relmns Bykeri) Shing » Lr ord tiple are adored collechon op
ba
ee ae of operon that con dan Peformed
« Lick t- Let con contin dala dikjgrren- S.
Swe items sted ign) tre isk ane Daparaiech
with A comma and endased wilh wqpiane beackal—
Ane 4 colon openaive Jo Juned do acron dova..j
ayne Lis-.
Cortatenahany +
Res Eas Sie C1, hi" 2.07
oprober arch
© part COD * hon
® pwr Co ca.) Operalis Can ba
op "@ 1 ni, 2-04 suaed) coh Lis
one 2 ore) tuple.
@® 1s."
cSmilen to de List ,it aboo
sTapie t-PA tuple 2 Similan ;
“conta tra edltechion qf, iiema % eit gk gree
Aha’ items @ the Juple re sp oend
tard exiles 5 PUMA EE “o
eke Both and we. conglk mocliby Hea Size ond
value ths ikms 2 tuple, Hoenefree We See ee
ee t= Chie sa 31)
er 3 ink CED :
££2 = "hello! Ht fine. pee even
olps- hi, 2,37
Built-in Type.
age dle gr
Dr zeke 0 oF ri 24]
foo G- ae C cai)
op cade tae®
At None 3— is 5 e in knaon 22
2— Yr iS a Specd Ayp Pytren
Natl mienie., By Sane a nde vodue ak tS
Nora and We aype of wr aa noneyPS .
NS Pandions - Br is a Weds Gates
a pede. Ask , O9 on danchton. can ba
Aelgred and dedcaned 40-
aeP Pr Cang Std 5
b\oad<,
AG odsde & Qn python
Oa Sor of, Renan s aro rn on
in ohen applicetton ,
suc clagas > A claw is q calleckon of clot
member and! methedlo-
fe fs claro ro
in 3 _ hhc. membn dey ond,
melhod cleclarah on.
snodste 1S afie Cenvain
+ do aie
“atenrol “ty
CE. aiPFenenr water ned Aye. Ovied- ,
@ Code Objed-
on Sounce code. —thak can be
by exec) ov coal () RIP
|
|
|
|
pes in Python TaXn Ratren sthene ore,
t- Ane code Object are covnale
Compleat
ap zielim Vole. . Sich objeds Gor vbe execudeay
e© Pease, jer i Do_Pytron, ane. Pare objet
Daprocent “Whre- exeenlion Stack = FPoameo «
ae Add are data sreqipived by AR inkerpacen,
wormenh, AINE
@oouk Suntima |xecuhon Awi pals
attibuke. 4, iF ane CLK fo pure A
Promo, coke objec that is lt be exeaukeol_,
cusment _inshuchion che. Even jon col
repulk ina new Poama objec.
ID “Beacebacke “Objed- 3- An excephion 5 saisedl
eohenewn an ehest Occurs in phon . OF ane
nok cought cx honclled the inknpacko oo
~pacebacl< _ object cxealtol when an extephon CCUM
Aho Jordler ci exceohon co a. amen the
—fracebads ie
@ Slice Objecr ¢- Anis enabler her elifpperer
® “types of indexing Sah ao rnulhi climensiorak >
@tede indexieg anel indexing frog ellipsis.
@ elupsis Objecrt- ths objed conkin a airgle- |
nome. ellipsis ana a hoolea velue «
© % Ponge Objet & otW's objec 1 toecl upon te
crahion & Lange alak Sek Gnel Limikal memes—
@
Stondond Bee Cpenatorm %- “the operator cox ba}
deRned ao a vaymbal whic io Meopensible-
for a ponticulan Openation behseen two Operonda
Petron provides 9 Vanieby +, opal whidr one—
AsccBived ao Pallas
+ Asvtnmeatc Openadsa 2 - These Openady.ane vused
to pagan jenithmerte openations lesween)
theo openands, |
|
|
|
|
|
Actliten + Exponent he °e
Se Ploor Divicion // COP gieo
Peres a the. Poor value of FA
pe TaD, guohenh precluced by
i Reminder’ °. olivicing the two operancto .
{
. Companisen Opeubyr %- cthece operadxs ane |
ayed comparing the value of tha foo operand
ard sehmy booleov value eijher True or false _
== eq.’ z= gpcakn “han yah #0. | 9
Nor Eoya) b= 2 grain tran
Lero Aran eayalt> <= & Jeo than.
+ Assignmen- Cperoyor 2 - his Operas ane usecl
to ain the Value he oright expenin JD
ane dept operand) - Synboll ward bt anignman}— |
Bb.
opens)
anmignment Opaohy i- t= -=
eS Aagemenked
. we ue whoo d= 4a
s olp cil he |/@
« Bihoise Opener '- ints operate Penkgorm bit Ry 7
pit operation on “he valueo .
and GD Aegan wo Cri
Vi
> vino oF | > daigt Pie ie
2D ih Ror Ae ee 2
trang nar? SOY
. Logics) Opecos 3 - BP we want do make
detipion Jbaced on mov thon one Candilron jen]
We Can sos Uegicad and ‘ond o¥ opsnahoy .
Anne one S “typeo of, Sogicad Operator
and os Tok
+ Membenship Operator ¢- Wis operates do
doed do check the membeuhip Wolue inside
a dala smc . SF he value ic Jprcoent in
“ne data Studwe then it secs true Other
Polos
> in o> Se is Coalucted fo be me. iP fhe
Pix openond 1S Rud im the Secondh operand,
Clist, tuple ot duds
> nok in t- OF iS Cosbuled to be te fh the
Rar Opeond is nck Bund in ta Deconcl
Openond .
fos \~ X= 24
ee TEN
We Llo,20, 30,40]
if Cx nok in 2):
Pan C'n eo")
Gow & .
iF cyin dD;
Pon (% welvemn™)PATCHY aue)] ehMreree Present ar both wiles dono\—
4 same olQieth
CipeeOd fis not ¢- SF So. evaluaked cto be dae TR Ke
E Raentily Speer “Sipis” openaliy anc used to deud®
Wheaten belonty TO
an demen-, Carein dlao os Type |
IS 4- BW is Gooluokd to be sme. iF the
Delgrence Preces ab both wiles Points dp the
int),
Poin Ay tre Suma objec.
Stendond Noe Duilk ia Rrdion Pncion ud a cblock
of code that benfoonms
a Specific tack, ethene ane mainly two “lyges 4
Banchiona
+ ioe eefjnud. raton
«Bulk in Fanchion
Usen alefined! af oe - Slhe. won olebyined dounchons
ane thase. Rincon eshich is ckfginod dhe Worn to
perern dhe Speoip'e daok. Python Provide. the defy
ord to defyre, the Pachon
wae 3- olefy Parc? Canguirentd <
Rindhon block
zehyn expreicn
de} sume):
a del POs naw
ae ft, CiHell word) | 9-10.
Cath
Pe : Seven c
d = sam ©
Prink Cd)Doak in Raaton T\heoe Radions ane
Adgned as *ne—
Randios whose. “Radon:
ati ls pre-ddgned In
Ryfren.
TobsC) *~ athis Radien is Used to Dehn “he absolute.
valne a Dumber , Tt 4akeo only oe armumest— 5 hase
absolute. “colue ig te be sehmed
Rs = ako =mhe. aXeeiste. value et ano-
te aes Q) 1S posi. 5 exn iF the number
PRAtEG) is Seach. a
ole 20
allC) 2- Ahis Bnchion seh tue iP all items is
: paved ane tue othewise iF oicums Rilo.
oF HE object is emply hon all stems hse.
Re &g:- k= 21, 3,4, 67 olP
‘a O pr Call Cle) O “ne.
= £1)3,0, 4] @ Fobe
@ ponk Call Cx) ® Poboe
K= Lo, Rize] @ Padoe
© print Coll Cl<))
k=, Fabe ,S]
@ pink CaltCk))
bind) g- Ans Rancho dd 206e0 fo SE, sale ay
arepcosntolion 4 a Speci fed) integen .
as |
fo" Soe oe
Ai i©
0] ma on, pon SS ail value to boolean
non Zeno Chow “K) Tue
O Fale Pal
7s cee het oF
pont Cbood CE!) Tue
dia bo oie:
print Choo) oy
“prin boos cH)
Ahis Rochon up dived alo Check ushethor
Sinsknce( ) 3 -
an inSkance- of thar claw |
oe ain ae is
b adum oO booJean value
and 1
eae 8- lam Shidenk ¢ olp O “Tue
go = lol @ Raboe
agen uUTJohn
Sie Shien ,
Ask = C.1,20, 40] )
at Cisinstance (S17, Solent)
Oo ot Cisinabance CS Sha
@ peak Cisinskonce Cor,
this Breton v2 sted “P calcula the
po2d) a
powen a humb& .
é . pio Cpow €4,2))
a olp #6
rink C) 2 ~ ANS finch ‘at i
ise Ereen C = " roe wae %
Spee aint C" welcome”)
9 I ink CA)
Prot C\x = 9 x)stag). ~ MArhis Jyundion “Comenls a Specilyed value
i a Shai
Pox Ea- strcry))
olp 31?
peC) ¢- ofhis Findon ory
y Ge oinie sie om selva na, ype 4 fro
Re Gd = 04,8)
prot Chype CHD
. ala P15 ’om? ,2;? Two}
dy Prink Chype cal)
ole 3-
® Coetenre Cm,n2) 3- Br take poo mument Cc ype
winents and checks chethen -both ioe. the oa
“yee. SF po sit sera back the wane TAS
Loithoul Perlgorrni any comerion. Othenwise th Convey
omc ef, tne. type tho makh the other type and seins
he vpdatecl ore.
Be Gi coerce C3°4S,214)
(3:45, Oly)
coace C5, 32L)
(5-L,3°2L)
@ livmod Cnt, 12) %- 9F to Q dbiusren moclulo Rinchon
4 0 engurrants Gnd exchms a fuple
Containing Pele qporhenr and Bemaindes a> Cni]n2-,
nt lena)
@O)| int Cod, base =!) This findken sehr inkgen Seproenkh
4, a Shing oe NuMenic type object .
[potion aielum
Coby elo) Olhis
@ dong Oby oa 4 shnig Ox tumeyc a object.
steprnentohe?Ahe Stordasd “Wypeo_8-
on Model|
ta Pype. | Storage Model | Updlake. Model | Acc
“De
fo Salon * enmotolble. | “Direc
the tye Jhotd [otne value of
Sale diteno\ Sojed- canno}-
objec oo
ahs Scary initiate
‘Nr veraus Shoot vero Ling , Ploak vewuo double ,
Chon oy Ayre a Python Aveo Nok waupporr doko
YP pw poe “he Bngle chanoshen.
Pinkn $- A 0
D Python con ebixc mannge- the mem: Ce.
Br the user + Aerefyn poier aldtraco ecal
be actenedl,
int vows Short verus co Clke plain in
in python. ane Dtanclard thot )
Us ¢ ink y Shot and ple vw
float versus clouble 8 - Plowk in cae in wimilar
fo olouble in ch
Related Modules %—List 3- A ist sn Python can toe aefined ac a
colleckon fg Value S 4, dliblgnen- aba Sypen
Pytron NS one matcble. It means Wwe con mall
its clemenk agen iF is created . Ake ilem in te LSE
ane Sepanaled with comma and enclased coith Ihe—
KSpuone beadea~-
0)
all Li = ilo ,?tohn? , 20-5) ae Miopticotds
dre £52,345 55 P a “
ee ordered
Charaderishen 4, Lis 2+
> Ane aemenr ane Lis con acceso by inder .
> Hohe sts ane mutoble, Sypes
Operations perpormed on Lisk 8~
Companison a Hs
a= [1,2, Heo” F
hells Hello” J
qseb @=:b
olp Pye olp ~hue
i ith
List Inelexieg and SP
one element & de dl as be accoved sag
inclex . Fhe dew Shanks zen © and goso tr d
Ihe {yn Clement of, the Jig 4d -Sjoxd at O index and Soa
Q=CLto2, "Melo" ]
b= Low " Hello”)
te¢ U=C0,1,2,3,45]
a Cons S JIL = Co, 1,22 3)49 3]
21) = | N01] =o, 1,235
QtL2) 22
MesI=3 D1 Car4g = 2530 =
La =y mitra) 2 lobo
Mesjes MCS. 27=- C13]
max s- Listvaniable (Slant? Shop : Step]
doe Con prnk dhe Lie i backward elixchen cleo
by wasing rego en veulte.
ovine 2 os BY
Hoe 1 oe eel
eA gg sy SB!
mer 1s \
® Repetition — eins oprah® enables Jha List element
to be srepeoted amuliple fimao .
fr &- Le fou
Prior CL¥D
Qo
[123,293
olp o-
® Concatenahen - Ql Cencodenales =the Lusk menhoneol
on the either aside of, the Opmatear .
For ae Me C12, 3)
dt= £45569
int CDE +92)
olp £.1,2)3) 45269
® | Membership - OF aehms tme- i} a parheuan item
exisks na parhioulan Li Ofmwite, Aloe,
fm Eatus £1,2,3
pant C2 in’ DD
olp “Tue
Pteahon :- he Loop ao Uo ao
: Henok.
is- elements , core
& & wes Oy R239
Ro i in Ms
prank CD
ol” My
Re
© Ob io usu. bo ge tho J the Ln,
soy ox) ty uoed . a gh 8
Br &:- St DN, 1413 ‘
Ye
9 5 Prnr Cen cai) iar lem)
ole aon
Aecleting “te ikem ina Ash $- append() is seed! 70
aod jem in a List
fr Gi Az (I A=(1,23 J-f12J
Seoppend(!) | J: append C4 hey
append (2) pank cd) Input ()
int CID | yy | OP
olp £2) a CL) ied
Ip gin
by er@/@
Removi
& Olax
disk
Rs Sy
Imax Cisk) §
element fom the usr > srernow() Ld Laedl
fo memow. the element frem dhe lis.
°
S- — sremore Cindex)
oi 2 4
L= Mo, Wy 12, ey
Q. demove C2)
Stes pant)
AP = Cro, W413.)
— 2r srchens the maximum deren of the. >
he &:- d= Lio, 1, 12, WD
pone Cmax (19
str = "Welcome"
s = LiskCstx)
Csta)
(poe me
ole Dry
alp Hl
| min(Qsb) S- PB sem the minimum element 4
ee De flo, Njl2, 4
Penk Cmin WD 5
olp lo
dist Cseq,) $ — OF Convenls any Legunce. Dp The DgWY
@ |Daehiag “Taple &
Tuple $- Py then —hple. in swed do She the.
Sequence Og immiable python objeds . The
s~upe is immutable. and the me Hh he items,
Stored in the suple cannok be cha » A tuple
Can be corlitn ao the collechon comma
“Seponated Values €nclased With Sets one mutable}
eS Means ue con medias ik on is coealton
oe dd MO \ndex attadied to the ements o% A
NS Es oahea oy aceen any cement
Of the Sd= by the. index. ire can parr trem oll
reqethen ov We con opr he Nis bh ements by
for oa) - or Linen"! Tue", +> >)
d= "Non", Ayton Uded" 2 Neth! "Pai", NSaur", "snd
© print CAD
Re i indi
@® prank WD
olp '
QD $'Hon) , Tue! » \(Oed)!, Thi")
ln Men
The
Wed
aihy
aal
Sak
Sun
© lila Cn) Tae ony AE
pacing item to the Set 3- fae Provideo acd C)
oO hich con be. ward to add Some.
eis jem —to the sek othe acdO©) vin wed to
Panne Je Clement whenean uplak©) ir used Jo
oe e elements do He Seb
a
Pat, 'Sat’, 'Sun! }a Si) ali = SerCL' Hon",
ink Call)
at add CXtha")
oll: add C" Pr)
dt add C" Sat")
pink Cl)
olp : £'Non’, 'Jue!, ‘wed! , let! , pul "Sab!
@® a-se Cl"Men" "Te" "wed" J)
Cc pink)
db upelode, Cth) MPa"
Rerovirg items Prom thesek 8— Pylh
and seme) which con be uunad do siemoe. He
Prom the so , Diflyprerce, bo” cbiscond G3 dheoe punching
ng obiccand () Fandien |P the. ikem dloeonok exist in
ea the See. remein’ a usheneao eremox ()
Sap” )
on provideo oliscand
the Ser
c will though an @m0e-
. [Onion g, 400 seks 2- “he unien of the. hoo sels conn
all the ikem hob ane. proanh in both Ho Seb
oN at! (3043
au f@%5b 45 -
emscthak Commen in both the Seb
a= $1, % 3,44
dre £4,%)2, 3}
print Ct & dz)
olp 3°72
Depererce bohween Aww se 3 - “he clifenere, of toe
se an be. Colaulated Cetsacieg OEE
lhe seoullng olp Ws OpSrahion toil be blaine),
that elemen qf, A which Is ok Prcoent in te Sr D
at = £1,2,33
dre s10,44
port Clio)
olp 3
. (Synmaaie Didhyrene. oy doo Sds. 2- 9+ ts cole Dae fy
A, Me emepo he Gemenh Which io sprcen} in
both seks.
ew By - di=f1,2,3, 5
db fl,2, 1%) 183
ant Cor 2)
op f3 4,17, 194Ser Companison 2 Pyron allows word wae he
enc Necro tte anon
Whethen ag ce is Subse y Supense- “or equivalent to
othe, seb Ame oe Bilao ts srctuaned penchng
upon the ikms — Proen ihyide fhe sels.
ae ats $1 2,3, 45, 64
dees), 2, 34
de = oh, 105
Prine Catrd) =e ol 1S ne Sepemcr of da
prin Gis 42) tt cla. ts the subset of ol
prob Cd==d3) A
olp Puen
Pale
Pahoe
Poozensee 2- She elemenks He Poin se Canno}
be charged afer the coeation. We cannot ox
append the. content & the Pow sem Joy Jing He
matre). Like add om aemoveCd
Be Gr fl 2 Roeensh (0% 3) WED
add Citem) 2-9 adblo an item fo He Seb.
deonl) F- Dr delelko all te ilemy Pom tHe Sep
copy 0 g- OF mehinsg Shallow copy & He Jer
discardCiem) $2 Pemereo jhe speaijed Hem fem fe seb,see
Onicade is Ha wap of Asc! cod &
Slang bo Shang © Are caiedion oo ae
Surrounded, by ping qpaleo , double qs oo tiple
apstco. , Bn pyien ‘Arvin ane. aloo coded tre cole chic
of, vattode- Chonaciel.
Drow to cacohe_ ring 19 Python a-
Pox ae S\ =" Welcome to tne Sar pogo”
sr= "welcome to Ae Rut Pree
sp2 Weerme Jo
Ane Pixs l-
progeain"?
% Biple qoteo one | Row srepxeny He.
mmulki\ina_ ov doc-shing wWHilina Sh
Sraexing and Spiiting of ag 3 = S="Hello!
aa Hee. \ SC.
on 2.3.9.
print CSCI)
pant (803)
op oH |
e
yor can dine cob opcnabes so accen the See
for 501 = B'theuo!
Sfor] = ‘Heo!
spis) =! Hello’
S(O; 2) = He?
Joe con accen dhe Sho pom backscand dy swing
reg 9ee i Hed Lo
ce
‘ lo ena eed with Shi S\="Helo" $2= "Woadd”
e d
“S-y-3 -2 -l
Stal-lJ= 0
StrC-6) =H
Sta £23", -J = tt
a. ae ee Ot Semon HA
chases {0 Shing sbi we can ddde- Pre
entine ai ty ane oe Repoced
fos St= “Hello!
dadcsi)
Synbok Description
Examp)e_
pas
n 1s KA GD Conaakena print Csits2)
Operas which is diced | olp
+o jein the whi very
on We ane a q He
opanolo®
|
x [Dr is Known ao Sepeiton) prinr C822) |
opsrls. St Concalenales cooalekoortol
oO
the. multiple Copies of Ha. : a
Sama
fp] aris Kroc an Ske | prin C8103)
z. OP do
: oO
Ree the Subshing olp nell
eH) 9b is Known ao shice |po(si £0235)
Pera Dhich is Pp lr ip
acces te oferabor from he Specified crong
OT 1 7oO
FW is Kroon ao membeuhip} print
5 “ Exainp\e— |
Gre in Si)
D]tsring Handling Pinions st= "Hello world”
oid 2ogo"
—
op 3
Panchon | Deocaiph'ern Sane
hen Cstn) qhis Pirchion — pant Cents]
4 oo olp J
a xg
CopiteLize() [9F o dhe print (S2- copitafizec))
Jeter of Stag olp Hello
Upper case
Count(t7 ,bQ!9*| PF oxchums je rumbor oy point (si al
senda ) end fire St OCcuu 0 Je
tg SEM: aa@ |Fird Csta, beniny
pie
end)
(solmun ()
isdecimal ()
iscligit oO
ee Or Ble |
()
ieeenaih ee ei
Tt aehmy Puc if fa ar pro C
the gino sing | 5. erchioih C'Jd
enc with a Shi Oy dencsid))
iia ares olp Ime
Dehons
oe vehoms deinder (7 GS-5,
Value of, the sioing \prin (SI * Prd C2}
Phere Sy 1S 0, dentst)))
olp 2
D+ cheda wheter de | Boe bg -
bog is ing tho
Compinahion 4y Spina Pook CsI isalnun)
lord pumbew. if, IF iS So olp pul
then ik crdyrns Puc
othenaie, iF oreluands
Pdor -
Oy checks tether She Ry 7
Bring Onbins print i isdecingl())
ni dip LP ap Po |
har j)- rehtans due pnt (83 iden
siete op Tae,
|
9r chedes wthelhen dhe foi 2.
weg Crain only. [rr 52 sdgir))oppenC>
D+ oem tue iP
all tha chanacleu in
oe ane owen
Cane
DH eehns de PF all
the character in the
Ki ane upper can
adhuns Je. IP all
Chanaclers in he Shi
ane. whilespaceo-
Cone Chanaden into
dowen cone .
PE coments tha. dower
Cone charackn In 4D
Uppen Coe ,
G Print(S2- bpecet)
De coments the upper. | Rw & s—
Prot 33° ischigtd) ))
OlP Tme
tow &-
Pro (52+ isJower|))
OP True
Pont isoon))
olp Rube
fr i- .
Print CSI: WSuppeny)
olp Fhe .
fos & o-
olp fabe ,
prorCsi- dower)
olp
hello coral 2
br =
Pen CS2- uppet’)
olp “HELLO©
anchor | Deoeription Example
O) Seeplace (sto, | Pr Looks Ba ston! in br :-
Sty2, n= the Staring ancl. Wy
} a ‘str CO
[Strrame + poor sr aeplase Cs
ale select Sto 2p, nz srcountL),
Olp heppo.
® Starbwith(oby | 9} orehams fue. iP | fe 8 —
| begin, ord) |e Sn Shik IK) ygr CsI Skobeors Che)
4 specrfie Velue 0, ents)
: Op Tne.
| _p , ng wih. |? &g i sy=>as>
© | zhu) Pri he. Shing nd cn zhuCey
a Specipjedl 70
Ovedueo of the
beg inning
Applcahien Arca here toe endl, Lyhten
yen cel pe pa 27
ane
vaniouwr wea whene Pyften Can be
olp 00002—
« Dah Seere. : Pee
© Dala Mini * frome. Develipnen—
+ Nobile Appli'coren
. Amfoal Antellignee
» Hachire Leann,
¢ Web Applications,peer
Veni
Python ro 1994 ytten 10 ~ 2000
Pytren ic - tage Python 2) — wool fy
enn 16 600 python 2:2 2001 python ae~te0$
phen 216 2008 pyren 2
Python 3° )- 209 Pythen as -o0lh
then 3220 Python 3:6 ~ SOK"
Python 3:2" 2on- Pyihen at ~ vole
python 24-2024 Pyiren 3B — 2019
Dithorence- behween Papen 2 ard python 3
Parameters T then 2- Putten
, laa paint "Hello cooald ” Print Cl Hello uoordd
ofP Hello world .
olp fello world
xStange() Supports Stange) and | hae no AsangeO
Aemangecy: bom. bub Senge) will
behave dike. Aarergel
in Python 2
snextC) Araxe next 0) and -next} Hare next
method fer terol “J
next Clemen}—
input CD We con due bot Sew input) 1S
Sow-inpukO and aeplaceal by inpsbC),
inadt) Fhe is no endsTMHisa
[Collechien of,
Sedereo! clos,
Lists ane
mubble.
Uss ane
decloned vith)
Sqpane beaceo
appendt) ads
Q sir jem
Ol td
the Li
Sol) Soats
He Clemens
a gixn
A Eon
ascending > oe
in deccending
naloy,
Wpleo ane_
endesed uaith
in Panantheals .
An elemement
connok be—
added °
trough }upleo
ane OF
he elements
Conrol be. Scot
he Sel add)
acl a gen
Clement to a.
|Elemen's 50 te
se canno}—
he sosted a
adeOl
: Lig [ Tuple_ Ser 5
© The count-O) fore count’) [oth? bo 00
"Sumi the |orehuars the M-| count)
Mumber of Dy imeo Hee, delgined
fHimeo oe_ | Speci Ried elemerty
Speipieol appear in tre
‘ements iQ
jappean in the]
Sisk
$ the seunuet) cewet) is |Ges dhe unoadn | Clement
eur%o +2] nob delgnec| ed ehich — | cannot be
Clement Gye! in the tuple, | Bemis foe” srewued -
Dis)- oreing Me ee