Professional Documents
Culture Documents
A Python: T The
A Python: T The
MENTS
UNIT T DATA THPESFPRESS)ONvs, STnTE
Vauiou Problem
nginaering problama
Applcaloms python
u
solving
Tntroducton t Python
Rossum duing 1985-
Van
Pythen was c veleped by bjuido a tie,
thles aBlie,
lod, ile
tn tee pn lad,
a geneca! purpase. tntepe
1990Pthan level
languaqo.
Proqramming larguago
object oñented and hih
Rython is intexpraed
at run tima by the tes preter. So
Rrthon is processed t.
need to Compile. a Progam before execuling
there is ho
Easy to loarn
ceary dofned
and easily readable
A Python Proqram
is
s Vey sumpla.
|The trcture. of. tho Prog a m
Vorsatla.
Imago procass'ing
ScieNtfic and cornputalional applicaluons
*Ujamas
Ente prise and business applicalions.
Opovating Systom S.
anguuaga deelp mant
Netuwort Programming ard Prvto typing.
FSNUA
NEOey
DEPARTMENT OF
SCIENCE AND HUMANITIES
Subject Code/Title: Unit:
Python- TntapreBe.
Inte pralea
To execute a Proq v a m
n a highlevel Languega
rons la ting One line at a time is calladtntes Ppraleu.
Comslos high lavel Language
To translate a Pogram wntten
a
Inteproter
pro cassing
Socuco, Thteaprate odput
Lcode
Compilo
Pre Pre
Pocassing CompiloProassnMachino soutput
Souco
Code Codo
and Inteuprate
DHouona batwaen Comples
TNTER PRETER
CoM PILER
one
Scans tha entire
Program Translatas program
Compila bime.
transla Bes it as a low laval stabement at a
and
language coda ü
No Tnkesmediake objeck
Tnkamediata ojeck code a Geneatad Generaled.
statemanis aua
Condibonal control stataments ad
Cond:honal Control
executes Slowe.
Ereutes faske.
NSTTUTE F
DEPARTMEAUMANITIES
Subject Code/Title: Unit:
Inteuactva moda
When wo type tha Python proqram in unteacBye mode it
dioplays the rasul mediatoly.
The charron > the prompt the tntopratos uses to
ndlcale that it Teady to ente coda.
Ceg) 9 t
loo
» print (e Tntoac tive moda n python ")
Tnteractire moce th Python
ADVANTAYES
Python Tnteiackme: mada. i gpod enoueh to lcan
exporiment or Explora
Nosing in
un nteiactre mada. Convenient jos beginnars
and for tosting Small Codes:
D1SADYPN TAYE
We Cannot Gare. the Satemenb and hare to' relipe all
tha Staleman Onca again to Te-Tun them
STTUso DEPARTMENT OF
SCIENCE AND HUMANITIES
Subject Code/Title: Unit:
Script moda.
Tn Scrip modo , type python Proqpam n a l e ard store
the le with
wth Py
P ExtonSion and use the Unteprelos lo execude
the contanb of the Jle , which b callad a eript
the
does not aukornalically diplay rosulb.
ython Seript mode.
uwill use tha
the
In ordes to cea oulput Jrom a
python Seript, we
b 9
C = atFb
Pint(sun;"c)
Otp
Sum 16
betwcon Intesacti ad Sipt moda
Difeono
Thteaacin moda &ipt mode
CHENNAI
NSTUTUTE DEPARTMENT QMANITIEs
sCIENCEAND HUMANITIES
Subject Code/Title: Unit:
Dabuggi
us to d locatig
Deb13
Debu 99ing tem is populaly
proqran . Itb a
Procass
Systemahe pocoss
P r o c e s
and ectfying e r r s n a
datoch a pYoce
dlofach
or
a piece
tha nunbe sf bug
s
Types Ervors
Syntax EroTS
Semantic Erro7S
Runtime Errors
CHENNA DEPARTMENT OF
ECOy SCIENCE AND HUMANITIES
Subject Code/Title: Unit:
Complax
ard y tho imnginany pat
the noal paut
a=46 298 Floa
F Intog ype a) S b = 13 . 9 5
ENNA! DEPARTMENT OF
H eY SCIENCE AND HUMANITIES
Subject Code/Title: Unit:
Strings
Corsist
Stin
Stnn a sesuene ocharacters, Lohich may
ist
Tang D ornpound dalatypes often raferre
Python ofers a
ENNA DEPARTMENT OF
hHSTTUTEG SCIENCE AND HUMANITIES
Subject Code/Title: Unit:
l s t da . CJ to aCcass a n elarnent
We Can use tha. undex opocalor
üst having T eloments
Tnder Starts Jrom .
a
t a a ist.
wil have em to b.
tnder
ce)
Ce Print tl»t CI)
'e'
>tup = (10, ao, 'a', 'b', 'c') lor) tup =
0,20,'a, 'b,
To
To Creale a tupe a
ty tt1)
Kclass 'tuple'>
ENNNO DEPARTMENT OF
S L O sCIENCE AND HUMANITIES
Subject Code/Title: Unit:
>Sprint()
'a', 2, 3, 4,5)
Dictionary I} Contains
a knd of hash tabla.
.
a
Dictionavy datatye erclosed Cury braces
Dicbonaries are
keyValua p is
ko Values Can
e assgnaad
access ad wsing Sduare-
and
3
brackab
be almost ary Python typ
A dictionary key Can
'Age 2o,
Add':xxx' 1
Cea) dict Vame 'AnA
20, x*x )
dtct values (c 'ABn'
Prink
Prink ldict)
'Nane: PAApge';20, 'pdd':
'x*x *
F E N D A A DEPARTMENT OFF
SCIENCE AND HUMANITIES
LS
Subject Code/Title: Unit:
Boo lean
Tho. Sumplost built n tye in ython the bol typ
it 7opve sents tha trulh Value» Tre or alse
>s x= ruo.
y = False
leg)
>> type(r) typey)
Kclass beot > class bool"y
Nona
> a =
Variablas
A Vari ala. is a name tha Tefers to a Valua
Teserred
memory ocallons that etores
Vari ablos are
an
thsBruc n thal tho Python
A
A slalamep!
eecde
interpro te Can
AssignmcnB slalements
the Value to a riable.
Assigns
Phint SBalement
print la)
too
Tupla assanmant:
assignment to all of the eloment a tuple
An
An
slatement
assignment
usin
LSi ng a
single
allows a
tuple oflaviables
By using this feature
using
to be assigned aVaues
ues from
on the- let the
of an assignment
the asignmen
a tuple. n ight
a,b: lo, do
Cog) Prtnd la )
Print lb)
two Variables
-
Tuple assignment
) Sunyo
Suay
a =lo
b 30 udped
30,10
a,b- b,a
Print la,b)
es
Variables tha left and the nunmber|
Tha number of on
GHENNAI DEPARTMENTOF
SCIENCE AND HUMANITIES
LCNOLOey
Subject Code/Title: Unit:
Com ments
starts the
with thehash character
A Comment python
to the end of the phy si cal ine
and extends
b
Very easy
oComments ython
Hakang
Ha king u se.
Cormment lina. t o put Code
Qan un clude. a
Ou Code
Coce ard
Can
be used to explain Python
Commcnts
Tectablo
ma ke. the. Code more
hen tosting
to prevent execu ion
Comments an a uba
Code
uotalion . . . "*)
*) for
for
Tiple
ë alSo poesle to
u
It
multiune lommeni
They aue
une Cormmens
Singla
-
*
Multi üne ommen
ommenb :
Sngle une. wtth a hash (1) Symbot and
wne nment bequns
Singla should ba
Should
A
thal the whola lue
menti oning
lune
une
we-ful wndithe end o the
Consi docod
omment ntund
n.
to a Vaiakla
asigns
n 50 # 5 0 value.
#
i n a . ammenls we
ua necd to bmment
need ommenl
Vhen
Mull ine lanmen u s e ful
double quote ("
duote
lines. In ythen tripla
on many used fo Hullne ommen!tng.
and single quole ( ) are.
Author ; Ann
Dept CS
Se cdion A
Literals
Litoras a raw data ,9iren
a
Varia bla. (o) Consanl .
Variaus tyes o terals
terals
thee are
Tn Python
Numevt lerals
Slri nq ilorals
Speial lorals
*Boolean lerals
Numerii terals
immutale .Mume7L teras Can
Numeric tnas are
be lorg
belorg to dferent Numeri cal TRS
loati leval * Compler tesal
Intege tera
numbors
kegular unteq Nomal tnlege
Cea) >ya = 525
>print( 166
b
Sloal teal f-hs.a print (1) oudpu 4s.b3
Complar bile.al >>a - 413.5) >print (a) oud pud4t9.5
Booloan Lloca): >S a ru print (a) adpd Tua
TTuo
Stnng tea s S: "siring
"
>>> audp String Jitexal
Prin1 (s)
Spocial litoual s a : nona }a==none DudpdSpeuial
iteral
pTnt special uteLaj
ENNA DEPARTMENT OF
SCIENCE AND HUMANITIES
NOOY
Subject Code/Title: Unit:
yacadanca fopeas
thal uod lo mani puloo
Oferalors av the Construcb
avo
ncude. 4, - . +
the Valuc.
o opeands , o e hasid oporand,
and
ILDSTRATIVE PRoRANS
two Variables
the Valuos
Exchange Exchang
in third Yaiable.
in
a- nt (input Ente the first number "")
the. Second number"))
b nt (inpul Enle
Print Before Suap") Outpet
pint "a -", a,")b=", b) Enle thanst nunbe
temp a Ente tha Se cond numbes 3
Be ore Swap
bternp a & b=3
Print nf ter Gwap") Afle Swap
"b=",b a 3 b:9
Pi "a :
", a ,
a = a-b
Foto the fvs numke
Entos the Socund nurner: 3
Print nfter Suwap')
"b= ", b) Bejore Swap
Print a - ", a,
b 3
a =
-
Pfte Suwap
Q 3 2
HASCIENCE
DEPARTMENT OF
AND HUMANITIES
Subject Code/Title: Unit:
J
Print (i,' Rolalion,&)
[,2, 9, 4.]
ar (1,3)
elurn dist
Oulp
beluwcen tuo poin
Pstance
b.9To5l214 847714
o
DEPARTMENT QMANITIES
SCIENCE AND HUMANITIES
Subject Code/Title: Unit
Cerum 8.84
ar Sun3
Oct pu Prnt('sun: ' Sun,'Av9:, avj
Otput
Conigrade. :45
En tee the Fnle a IoD Ente b aco Entec 300
Arg 300.
The Jacnhe?l - 13.0 Sum boo
a,b b, a
Oudp Prin" Afte svap")
Enla the faicnheit yale. n3
Print a =", a, "b- ", b)
Con 19ado : 4s.o Ouru
Entea 1o Fme b 2o
Bejore Suuap a =
Lo, b: 2o
a 20, b=o
Afte swas
S
DEPARTMENT OF
SCIENCE AND HUMANITIES
Subject Code/Title: Unit:
cHENNAI DEPARTMENT OF
SCENCE AND HUMANITIES
Subject Code/Title: Unit:
Tuo Marks
Dofne Python ?
Python s an objech oriented hgh leval language
and mu ti purpase Programminq languag
'tnderpreted ,a na mic
Tntepreted longuage
Cross -plalfomm larguage
Froo ard open SOurce
+objedoente language
*Extens ble
atte 01
a humber that a pmgram manipulaBes.
a
Python ?
Lis He standaud daa typas Python?
TYre NumberS strings ist ple
Dhetiona
NSTUT DEPARTMENT
CHENNAI
RSY
OF
ScIENCE AND HUMANITIES
Subject Code/Title: Unit:
mode ad made
6.PoLanta betwean nteLactive eipt
Tnteractie modo Scipt made
A uny 1 w g he Pythonn
P way ing
the Pythan
ntepre te tread and exeuke
nte pretes statermenb
ytypig Statemenb n a ipt
at prompt
edit the ade
edt tha ada
3. Can Sare G
2 Cannot o ve and resu l t
no See the
se can
3. e can Sae tho resulb m medêatey.
nnediaely
by an dlantifer
7 stout tha rules be tollawed Cundetscor2
Comnalon letters, diq.t
Tden"fier Can e a
Deneunchon
s b pmram
Whuch Conss
sts of sels sf
a
Functi on
tosk
tnglructh ons
webpeform a peufe lage proqram
,
A
10
Defina Expressions ard Stakemenb ?
Expressfons
is a ombinallon f values ,
variablas
An kxpressi on
ae
at
ecubed one a
SBatermenb
State ment he p
tho an
Ceg
cog da Sum la, b) :
Sur )
ine modules Python
A madula u a Jla Containinq
then aRHon
uncion taBomants ard thstructona
CHENNAA
INSTITUTE
TEHNOLoY
DEPARTMENT OF
SCIENCE AND HUMANITIES
Subject Code/Title: Unit:
kozpord augumens
peault angurnan
Redurergumens
thraading
Collechors
strin
time
tknt
ENNAIC
TCHINOLOg
DEPARTMENT OF
SCIENCE AND HUMANITIES