Python
Python
Date Date
+oo Puthon has simple suntay iillar to the Ergisb
NocO conmol panne | AdminishdHfve
goto
PyMon nas Sitax n a t dllows Aeveloper s to
go Ho Is manoge
we prdgram wim fewer i n e s than SoTne
DHner Progommn
Cinguoges
pytnon sun5 on an
iotrpreter syshem, means
thar code cen be execurec as soon a s i is
Python
Python s simple oniect-oienrea S Cmpt n
an
Features
obiec -osenea)
of PyHnon
wcy Or a fonchdna way.
1 anquage. More than scripHng we Can do many Easy as ir is witen i n Simpe thc i s h leina
ings because ir has lorge ser oP 4ibro'sieg. 2 Expressiy e ean easily undessand e o r me ssages
T i s most popules yfree & open sounce softwce Free opensource Slu
is vsed for- 4 High1evel ianguage.
web development (Sersu ers-Side) Porta ble L r e TvM, ir hus PvM (y thon virdual med
50fruwore developmenk 6Objech -Oien ed langudge
snathema tics Extensible w e Cn imp modules we wanF
Ay sysem scriping 8Embeddable Combnin g w i t other }anguages
wha Pyhon cen do a Interpre hee
PUton c n be usec on a senye to Creare web 10 Lorae standard SDruy
Ppico4ion develope aames.(o6o for s/u developmen
}Langusge developme) GUL proqamming
pyhon wn be useel alog side sofruttre to 1Dyncamt cel iy pecd tore dcake tyPe
(redke orkPlous dutomaHally,nerel nor
Pyhon con connech fo daa bas e sysrem. T Can to qhve cler ype.
olso yeod modiy Gles. Rules o Pyhon-
Pytnon (an be vsed to hndle hic dareA p e Thee ts no tusty bTaces to deine a block of s atema
Cermp)ex mdthe mel S, No necesso to 0se semicolon (;)
pytnon con be vseal for Yapic rotouPin we need to vse colon (:) ar +he beginoin of
OT for production -Teady sokwne evelopment eNem block of shahemenk or f e h o d , însheole
wby hon:- oFopening closîng Cusy lbraces.
Python uov3 on derenr Plat forms ihe 4shinq Yalues aTe encloseel wih 5inee or
windocos maC Linu, Raspberry Pi, etc) double g r hpple doubie quoels (for muHTine
shing)
21ogice opencatovs a r t not Symbojs(4 ! 11
Page No.
>> a = b:c = 10 assignrnen aar chcune
3oPython those care ods(and or hOt)
Variable must be iniHalizeel, w e a no 7 Print (45:56) 1 pho Hn Nalue aven
ony define Vordbles (ex eno X, eno =101 4S56
30
hile Loop
X
2 a,b b, a / Suwapping d lues
>> Print fa) Print Statenen for vunable wlhile i<1o):
yaue Pint () hen mn no. i's invalrd'
Print (' ncto uworld ") 1nninq Sta temem
Helbo cwold els e:
Pinr no. is iovalic )
Page No. Page No.
Date Date
DcHe tgpes
I-else These DatatyPes r e inbuilt in python, by ce
X
by defaulr i t tores doto Agpe automoticauy
age - 24
>7 if (age>= 18):
eligible Ao vo e') Text Aype St
P n t you oe
|9 NUMeNc TyPes 1nt, Hoat, Complex
else
Piot you ave no t eliqmle to NoFe) Squen ce Types 1st tuple, range shing
Mappng_ TyPe dict
i E wil ppot uOUY Oe eligible tu Voe"
5 6et TSPes Set frozense
6 Boolean TyPe bool
EX t -etse sing oicod
Bnay Type . bytes, byreoay ,'memoryvie
>>> age + 24
ueignt =60
i f Coge zA8) and (weiah>=50) Function/method
PrinF y o u omre eliable t o donde bloo TO define Function/method weUse one kelu
else. Cclled det
Priot you are no el ig dble to dondhe. b}ooc)
d e f add (i ,3) i o +his woy e Con e F
oolecAn- dctra.
Page No. Page No.
Date
6Membership Naue/i0HN) .
Ideniis ex
2 . 0 / / 2.0 4.0
-11 /3 4 11/o//3 = 4.0
4Arahmetic oPeraHor
2 Pyth on Compaison dpenci tOS
b 20
1 AddiHon ( | Adcl values on eithes c+b 20 ides of +hem decde he relcaHon amond
Side of operaOT hem They ae ellSo cealle c relctioncd ap r
non-zena b) is
any oP he ttoo s
ov
r Asres Moeu los oSte duyo gpoc1nd OR f te
. = a i5 ¬o(a
asin ne resul 40 etf to C= C7.a then c oneditioo become
opGTund
Acefes e t t s peH¥ormS MOT Usec to revense the togicet Ste a£b) s
epanetia of sopenand fale
Pege No. Page No.
Date Date
6 Memberrship openatos Avwaus
The membenship tor membeahi Tt i6 a
0er deinead
opendtor des Noiable to StOre
Homogeoy.
Such as Shincgs, lisks, OT tu ples similer)
n Seouence Pes Elerments in a Conse(utive
Oprh0T DeSLmpton Exomple mernbeT locaion.
in Evaluts do tue if ir X in Y Here ns Ecch jrem sBored n an
aTsay s ceuleol an
ase othenus e nor a member of The ength oF he arsuy deines +he (apuiy
Sequen ce Y to stoe the elemenks
some besie Oy opeaHons
7 To denti ty opera tors. TraNarse 7 priors the elemenrs one
A is Coneto numbers
Con ceinnoF ehirge add ar emoye elemenrs
Shong5, 1isks
tuples , diteadian dictianorie3 ohiro ee om Ahe tuple .
Lists ore declo rees S i n g Square bra chels
around p m m a seperaèal items.
Page No. Page No.
Hands-ON Kuthon 1 Date Date
end= énd-1
1 2 [stard end wi) mafe s chnuncter celpeu.
S e t e h
ato] = S 7a[otD.dppes 94at] shwer' p stu
19 possi4ion
2h - 11
a [a:1 = S o to(1-1) =* Shwehesh
[o: 2] =3h 1o to (2-1) e 01 7 Count (s) ouny no.of s o/p 2
Shwe te o to 6- 1 ) i o,12,5.4,5 CouNF('e',o.6) / no of e' Steynq fsom o tol6-
a
[o:6 =
ato:-1= Shweres 1/ o to
(-1 -1) ie o1,2,3,4,S, 6 > . encode Cencodinq Uf-8) /
a =Shuekesh whale wora
- \t
= Shuwerc\t 123 olp> shuerea 123
joinit* heo','uo ) lk hello*womd Pinr(c) l e - eete' I ' e ' , ' ' 1 ' , o J
i d CK) now caderess oF K.
¥.oin hello 'h*e*]*)]fo >> appeno ('mi)
nt () [h'e 1','0',°m'
> a . SpliH ines )
a.Shp word 77 lis(thello')
alstop (helio') = a . CoPyC) / i r wll copu i s r i d a Ao
a.Tsipl'uomd')
Doke 5/8/22
"
» a My name is shwele
|| \hello wo ld'
a.TEMOvE Prefix( My') l name s Shuea
list (a)
a.Temove sufix ('shuee') lp My ndnme is
hello cwosld
elto ld' 7 t p e (a), tupe(b) /tyee of dhes
a.rplace ('0',m') ol Hell tomtd olp clesss4' <class lis )
a-9 b. Count ( ' ) _
a 2 H1 (10) p o oo 00 09 b.index ('L') lp 2
dhelto
m a re trans("ha resh', 'shwekesh )
>> = a makehrtuns(harresh', shwees
>>> b= 'hello woTd3'
[1,2,2J
> extend CJ)
b. tronsate ti)
Olp sello o(r "1'o' ' ' 1,2',3E|
bjnser 9,1 inGen-1 on posik
b
, e,'T',','L'0'
Page No. Page No.
Date Data
7 list (ronge (a,0,-1))
>bremove -19
1 iwin pop vemoV-e 8 tom
hello
O n i o n E au
> [1,2 3,4
o b= La2,4 intersechor oly (omron
a.unionb)
for looP 1,2,3,4
> o . indensechion(b)
a TOnae(o,) 23,4
Tor i i n a >>> for in a a . d i ference (b)
Pon ) 13
el6e difference (a)
nr sucoeskuA) 1 00
Pege No. Page No.
Date Date
> . add ( 5S) PoP( slno')
>>C a.copsO
deptno: none oc none3
P o Pi hem
i1,2,3, 4,5F
lo , none)
Se theoy
Pint(in)
Snd+1
O= Sino "1
deptno" : 40 ,loc "
chennee bredk
'
a ceS )
else
dimct eys ( sino, 'depeno', 1oc'3) Pior"suctessfuuy execurta")
.vatuesl)
dict-vatue s ([1, 10, chennai 3 )
o . i temt
rems ([ ( sino',1), (dephno, 10)
dict
Cloe', 'chou an
>>a. frorn hay ()
Slno' i non e depino" None, loc': none 4
a.fm reys (o)
J
S'slno none 'deptno': none , 1o ctnone?