python notes
python notes
;- line lemina
pylson
C, cth, Java Pytvn - nentor
Comple
at once cno given emrlorupy
Sfatmeut ino by lene
(nevpet
ce lons Cveateg by Guico Van R
present we use Pyton 3
Gol ’Graplicaf User lger feace
osn
Dpen bource ’. modi fy Source (o de aud whte our
data yjpes
O Numeric eqets
Plo at
Complek nambens
The symbol >>> ii calied Pytorn prnpt
Interpreler is calleq pyton shell
fypu of Modley Run/Fun Modute
Interaee Mocle 3^
Schp*t Mode
le.pç
1le lnerated alev elop ment ad
(earting-35
P,thun eyho ords
Env onmen
ldentifiers -
coe names wsed to ident+hy a vauat le fenzli
entihr in a prgram
special symbols wke !.0,4,6,.
in identifes
’ ldenifer can not stat witf a igit
A-2, a-, D-q (_)
Vaiettes -
Lt is an (dentiet
(dentiher wliose value cat
caange
num= lo
num - Q0
b o
pint A)
Gutput - az
f Boolean (bor!) is a
tons tat
talse true
tre Valeee is non-zeo
’faue'yalue Zero
Sequtnee ipe
Sting. kist, tuple
Cuareetetg
Sting
tie valu er ay e ehlosed ti tter in hngle
quof aton marks oY in euble quofatien mautks
tor eXample
Str : Hello send !
pint ( ext 2)
Tuple 8-ei: a soquence ol items spahateq by camma
ilems encloso in parent,esis( )
we rannot clians, e fleme in te tuple
,
tpe
Mapping:- Lt is ar unorcled olata edeNB
Pyeton
Cumen Cy,
y. th eve is on ly One
standland 'mapping
data tope in
tn Pyton is calted Dicjonany
=key vatue, .
'a': 1 ,'b': 2?
pint (a !e b) - 1
print (ac- b) 1
pånt (a >-b)= o
3. oqical opoatos
b=5
t ue or falie
NOT
Te
given cpresin a2b ND
not Cab)
not CF) ’ T e
exprekion.
4. ldeniky op erator'
(E is we to cornp e the
t7 ey one equa< but if th ey ane açtually tt;e
Same objeet witt Same memory (ocalion
aapen 'pent?
pint (a it b)Falle
pint (a Ts not 6)
Teee
phnt (cit ) ue
tos (=)
a 2
6helo
C= 4. 2
2t 4.2,
6: 2
AHMMRMiHlMfAiliffilHfil
S
Dporators
Bituise4.
Deimal
6 3 t Deeimal
’ -’
Conversionof
Momoy
Hexadec?ma oetal Binau
Tera
byte Giga
byt1e 1 nibble
ubitr 1 -
(o| (00 Binay }n -
Mega Spares o o,
Binay ferms (e to+
(t) toD I
byee
-
(e)
measonf
of (IF)(6 tu, o
deeimal to ByteI
(oQ4GB lo24 toF A
KG in
lompuer
Convesioo
2 2
24-I
24-L 2
2-1 (0’1o1).(ol
(9-L 39-0 2 2
-O 2 644 loa)(Ox
=0f
2-2+0 (ora"2°)
Io-1 23
6 of
-0 0+0+
ema
8
t442+0
to
Binarut
2
2 9
9o 2 -0
362
22
=044t2tO
=6
2-0 4
12
912(
34
AND 2/s6|4-0
2
2)3 2
Ostalie
|-Tue 2
2-/9 22-0 o 3-0
6-
12-0
Acud
BAB
2 22
2
)
igutife 22-0
24 -0
|
And 2 S6
auf ’
0 t0
10 ralion,
op
NOt .2 |11000
4E-
16+
6H
2=
2K3 |00| |000
|
2%3
OR
DR
-A
auado m:8
* "
)x2 Riglateift
(>>) Deumo Bina
()NOt pouiXORC)
6381=tlo
to 2s t'e Tbolooo
to
decimal
bineyCompliment
Compiment
valel
wewe
have have
22 2
to to 2/63
caleulate 3|-|
neg
2
lect
2
2(2-0 Kero' 2-2-1 lo0 20-0
2) 2
-0
les 22-)24<-1223-02 2/46
o 6
I00Jooi ceidoy
213
236
j0o 2 |8 -0
29-0
24-J
9 22-9
-0
2||4
2 4-|
229
2 4-|
21-0
4+2t@)
2\3-1o
|-|
left suift (24) (in thit we teke aftCt ako)
2
Y22| -4
263
’632e| =126 231-1
2/i5-1
2[7-1
23-!
|26
*xpresson - 12
12||4 2 **-y= 3
3432-4.
’1|. , , -’+ >,
-Tue ai'yeton in wlitu any gi ven erprxiDo it
the Same
more than one ope ralor uauing
precedence is asse sed by Asocia bn it y
2 =S12
InputleuputHfnbs
input alap
Gutput
enter a sfing: hello
(oY)
asinput)
b= inpu J
asim ('2)
Cutput IpinsC)
1 Debug9ng sltving the vvo)
Puntime enor
a(onc.
b (tot2)
cafb
oufpr 34
Syñlax
-tatemeat is iynla tturay
a-(to1)
b= (otIS
Cynlax eoy
- exeeelin ill ctop if we q
Logical erroY
Sematir ernor
will nof top t,e otcuibn
ee ,if we i
o=(ot 12/2+(t6)
(to) ()
(ode
pvodurcs 'ncowect ut dur fro
floeo logie in th e caleuta lini
Runtime eror
termin ate the exettuon of
tF ws
program OUtput
a intinput C))12
b- in(input C)
a 2O
pbna)
a -ls
feec)
print Ca)
Scope Vaiabl e it t5e pat of t5e prtam
wlere it Can be acekeol , and it iferine s
how ¡t exists in memony" 2o
2-0
22
(-0
Io >> 2
ro to 6y
(o |00oo
statemott
44tlo
2] ti)
Helo
multiplines
ole qou
ese elif it(3)
else if(2)
etatementsi Conoioncy
C) fypeo
+
23lntCd) f
d='23'
Caatb
Expliete ’
pybr by type dataimplicf 7
->
auto(onuesin
chorging poeess
of the8-is comven10n (ype
au
lommen line for
o0 #ye
Multie
ine ine Singte
Conmen
prngrame
wnten ie Lt
Btson
lommat
20
ynt elheif- Coulles)is
slate
mevnt
’if -
indetatin státementh
wi
le
looping
for
else
;-it
satement <sfateinent
stmt Ccostion print
(a
): ie
even)
ifLlock
true
Te
stmbelte
etie
time ma may
witt
'in
yntaa more
wne one in
Wenab
elif
bynta time
bynta
in is is ('bis is
'one
onty in :it
C6>)
(b (°c (c
oite
Cit pint print pint prsnt
nera)
:(ar6)
,
negative,
’ lelie
elle
tver) -ve')
Cpostlvt, (ronditon2)
elif o)
(as
pint
a):
Sx is elif is
Caso):
if ritC):
(condilain gtatement
3
stmt
3
(o Caco):
(a 6,1
b,tS,
a,
sfmt pint pint
ee
if
estedi-If ele
fue ele else
eip
yntar
’
wite Range
Syitak ->for C)
([slartJ,
vange
stop,tunctuon for for
to vange a:Yange
(2,5)bzpsrt ( 4)
,0)(ist(a) inHeltofor i pi i statement
ctmt 1 value
o
#(o, [2,3,4 # in
values tit pint
(i) nt
C l in
-, ); (" sequenee
aud --3 (a)) GM)
phnt #
- -u, o, [stepl)
-§-6, l,2,3
-f,-,aJ
’
PriCint) i
in
Yauge
13
Kontiti
2 . ifCt.
=o) C):
(1)
fale.
’2,8,10
-’
yli
fo aoutput
2,4 ’ Cy2,3,4] a=
2C,2, le
i it (neai)
wtale n1
in (Ohellopint ) (A n
G7.
a --
print(i) =)
eoodtmornieey
Breot i 2
==0)
lo]
1
Breok
usecl
4etminet hellhello helo
or
Neton
,ony is
stup u
key
f1 tte
lobs ord
Sinqle3) 2).
) SThngsi- Continue -
) Con for
Repi Calenatim
6r (Ce pint ci) Ci3)it
e: i
dTo] h Held=
item
lo diHelo VH"+w"
i d: în
volues Lonttnue in
-fron tim :(I,2,3a,4]
double is :
:
- ae
2 a
sSenente grup
23 3’ * ayuotationencles
HW of
(stinq:-(inder eci
Hello clunater
metteitter
tello
Hello in
o
Sfring) ngle
omettins * )
eseape Iteratiòn *
lengts Helel-lo
membvnskip
oli forini denl-) pie pint
spaetaþ|t ChIt
pint(
Tuis i- ('
funetion C'Hot
hare, is printci) #H t'
The
ten
operates
is Crne wued iinnd)
B84' process (s)) in
double inge for d)
ka4 Specißc to sföng #
sins
#
ctey of 11 #Tue in
csciate False
cpace)(4 repeatiny
mcltiple
Code me Sing
meaning ;
wit . J
Gloce
cfrin strings Unicode
rele o
Siing in Ruo
’ exeleetion. stings
ern ’t ’aifernigate T616
by write pint
tings
biCll ) (t Loll
s:1#e slo s folons
specifying Lt wil C"
S phnt
dlroool
[-:-to;
-i# allows.you in ln
different
from this give B49
Hello the n
a (ting the ano
world fomat sfa egiti )
Janguages ercape t5er"ine
to P
sfringexlvcuta
and
långunge,numeic
canoter
incusjve end
world
hello [sfart
inelek.portton t%e
orl caau
shing
di(,2,3,-) ae)
(alc))
Helto
World ’ xC) is deplace 9
locercase ) Uppercase C
pint S-"He
pi oorldClo
"Tir nt pn S
t prnt print lopätS=Hello
uoer(S. wortd print
(s. (s-replace ntHello
world
. fundtión (s. ( (s- tello
LOOrlo
is ic statement (s.
alnumC alnumc is) stsp)) itip stnip
um upper()
ec ('Ht' ()
wnten ()
C) ef
) j]
4teplate leter # # H ())4
# the
Hello HeclNOdu Helwoslloel #
Folsu trueor # worle
Lello HELLO
jel o oonld
LOov14 Y
false ORLD
base