0% found this document useful (0 votes)
3 views

python notes

The document provides an overview of Python programming concepts, including data types, operators, and control structures. It discusses identifiers, variables, and the syntax used in Python, along with examples of how to perform operations and handle errors. Additionally, it covers input/output functions and the scope of variables within a program.

Uploaded by

rdhanush118
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

python notes

The document provides an overview of Python programming concepts, including data types, operators, and control structures. It discusses identifiers, variables, and the syntax used in Python, along with examples of how to perform operations and handle errors. Additionally, it covers input/output functions and the scope of variables within a program.

Uploaded by

rdhanush118
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

0,

;- 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

YenC nen Ltnem 2


poht (result)
leng tt is to unit oud breodt is ao'uits

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 !

we Cenot parforn num ncal bpejaleons on st nnss


Jt -u is a cequnte of tens separafo Lf Comal
i lema a e encloc eof in oLt ane baketL

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?

entleef wit cwly brackets ?


koy
data tpe
for exame
tier d : S'uit''apple', clinate:'cofd
pint (dice 4)

print (dict 1 [' pice (ka)')


>» l20 Sgdting valecky
to 2 Speifyingsty
Openates in Pytson lauquage i
t-Asbmeli
+ b: 2
tooperan
oporatoy
ttedulusC9et tthr rema'ndes)
** eponent CTo perform the funeiuonof Poe)
I| floox civiion (it will come on uy
tntege pa
Pet)

CompanSonopen attors Tyue : 1


c 2 false

pint (a !e b) - 1

print (ac- b) 1
pånt (a >-b)= o
3. oqical opoatos
b=5

TuefralscoR eitherone sde


C

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

5. Memo vihip openalor


b- D'pin' penc?1"
’ not in pint ('pen'nb)

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

opectov Preceedence dseribes tte


orde in wlice opnains ate ferfor

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

0.=tnpur (' eter a tóng")

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)

pint (c) diviSion by xet


IE Can bewf when a pqram
ermr ?n snput ,oct peut
Runtne ery
vaviakle 3- tof furln _naral ):
Scope %ife time of

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

pint (a) statement


t is an instrtion tha the pyl;n inte rpialer
Cen eNec l e .
(snsle staternen Lt
a,b, c 20,!,2 vO)bple Values)

- l+243+u+| for continous clantey


for neXt line

44tlo

ive tte Snsle


also give
se tis also
statenent oith multiple las

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

(s2=0) utile wtile(izn)z


t2
phnt ns i=it| pinlti) butput!
(s) for
l6

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

xclusie C6it-2e-2(6 dlto


erdtop of in
u t5e
’stn4e
strings
Modify : (add 4ormatfing
stiing i
i2 PC"Sum /ffloat
b=5 format
S:Hello
oortf pri
ont-j'tS(21-jemr nt d
int format
ae -fu?
() (1 sting
tnnelab
- Sum
t bo3fomar
le d".
lo forma(c)) ,)
(tan't

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

You might also like