Python Alok
Python Alok
shirg siclog
name = ’ ugh 5
indu o! 2 3 4
-5 -4 3 2 - <Native Dndics ’ wel hen yeu've
to de sonelkuny fum nd.
s [0:3] - 1etusus
Sma -’ chuyates frot 0to 3 indices
havact fvam 1ta 3 indices
si [13] ’ etuus
CHAPTER 2: VARIABLES DATATYPES
in
qivtu fo o wtmovy Lncaion
b:Hmy"
DATA yPES:
ex: 2,-l,5
5. None
MOpULES:
PIP:
Pif d the tackage wmDuDger for pytho
tetall a modula
bih do
cqytem
Ls pit lasta!
ex: pl iustall flosk intall1 flask wodule
Sticing with skip value
wt cam pkovide a skip Valus
ike
woYd,: "aMazi
YeBuYns mzn"
str(31)
itl"1) 31tim to indgu canvuitn
Hlont( 92) 32.0
input () function
is fuuchm olous thu as to taks input froe
the kuyubYd
"pythen"
MUmbu)
typrcaut it .
typela)
b: "3"
type ( b)
a- (1,7, 2)
1 occuYtd
1) 0.couutl1) ) Thes
in tusle.
hetusu the index AtYst 0CuYMee
2) a.Index (1)
! in a
CHAPTER:4 - LISTS AND TUPLES1Y1 HE 29UT
L1 ( 7,9," alexa"1
L1 [0] 7
LI[1] 9
L1 [70] Erroy
L1 fo:2] [7.9)st sicig
List Methods
conviduing allaaig
1 (1,8, 7, 2, 21,15|
\n ete
ula "kuy"vatue"
Ncoding",
*uorks "i00",
Dictionary Methods :
Covuiduwy :eo
olsing dictonay
warkr" [92,98,97) ?
CHAPTER :6- cONDITiONAL EKPRESSIDNsorsg
f dse and elf in THON
H else and elif atafewent ane
decist m takeu by Q rogaw cuet0 cevtal n Conditin
in 0UY C0de.
Synta:
i4 (conditim 1)
indertahi Cprint ("Yes") if condiien sa true
elif (condíien 2):
pHut ( " N u ) e f tondí hin 2
elce:
pintl"Moyse") othewise
SETS JN PYTHON:
Qs wathematca sets.
Poferties:
i) sets ane wuOYdeYed .
i) sets aye unindexed > cauust acces eleutb ndx.i
In Python
) olite Loo
While ao:
Oyutor:
ile c ondilan :
ek:
we Cau
also ecify the tst, stop aud teh-size a folous
Tauge (ctart, step, steh size )
fo i in vaylo,i0o)
break
Pass stateuent
pas4
walki!
l- [1,7, )
ter item in !:
pars
Functiant oth arguMuts :
pased.
x:
dek fa cteial(n)
4 n== 0 6 nt ’ BaAe cond" wich daeunt
vetun 1
else :
retun n factoviat (n-1) func" callig ts
factorial (4)
4 X fottoiat (3)
veod a wd.
with otatemeut :
binay kuot
in toxt wode
in ythan
rogyaums RAM - Volahle progy TnA in
i!
sai
RoM : uôn-valahle file qets ub dated
1yer files:
Mheu
i) Text file (.txt, cet)
") Binang Htes (g, dat , ete) y sli ihas
ha a et qumctou for eadivg updatig ond
deleting files-hbatwa sh heiriheri