Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

PAGE NO.

DATE

CHAPTER 4 PyTHON PR0GRAMMING

Rthon ChoLacter set is aret of valid choroctey


Acharockey epreaent a deteh digit charocter ond
cher mbol
Iython uppert he yalauing ajletes (a-2)
b) Digits(0-9)
c) Special Symbel , e
d) Spaces
e) Other characOS CAll oth e
loKENis the small est indiviclual element epython
sipt is Rnown os to ken,
Tokens anei
1)| ndenhficns
2)| Key werds
81iterol
|Operator
5)|| Pantuator / Delimiter

NDENTIEIER - The name any vaigbe, conglant,r marule


or funchicn i called ident hiet.
Ta i- Area = n se, area and racis ate idenhii

Raleo noming ddeniher


long equene changcker inelude letter,digit and
under core (-)
PAGE NO.
DATE

2 shoutd nat startwitha cliqit.


3) N space s allcwede specal characters are not allcwt
4)t case-senslhve
)No keyuard is allawed
S Arca, I, value, n, nad, first- hame

dentiy the valid denhikier and Re ascn invaid (2)


029 Clot- Invaicd(ldentiher ce nat startith cligit
D y file- InvalidSpecial Charaster "ipareat ottaed)
) Admno. - InvalidCipe oid chara ter'."
ltv break - Invaid (Keyuerd
Iv) for - Iny adid (keywerd is net alloeued)
v) For - Vold

KEYuORD - aloc kncwn as Rep erve ard.


keyword has special meaning fo he languas
interpreter.CP& thon )
No keyword i) cmed an anidenhiher.
» To show the ist all keyuords in Pyhon
>neport kewcrd
print Ckeywerd. kw list)

UPERATOR- is ward /iymbal thatperfom so.me


achcn(operahan on some qiven value and
9eturn the nesult
They are af diHerent categcries
DATE

DAlhmehc Cperabr
2) Relahcn a operalor
3) Lagicat speraer
4) Asi_nment cperokr
5) Shostha ncd/Arqument Aulgnment operaer
s) Tdenhy operator
1) Mem be tship opcrakor

PNCTUATORDELIMreRS - Thene are the uhich son


be wsed reparator
value cr to endose some valy

Eor example :- l2,3)) - commoo are cwsel g cpparator and


Oare sed to enalose.

iTERAL -"Literals are fixed numeric Qr noh -hum«aic


Valueo
The value literals can't be changed
curing program run
Literals can be cf any type ie integen,
numerictet and othen.
Rython supporti he follauaing typesof líiterali
Integer iteral ex i- asl0 b=6
FLOAT Iiteral ex pz2.5,=6.3
Shing literal exi- name =Kapil eRav
" BOoLEAN iteral ex i- True (Folse
" None iteral : Speeial literal indicatea abienc
value or uncdenhhed value.
"Collechon literal coroiat list or huple.
List =[ ] ,Tople = ()
e*:-C,2], (2,4,5)
Variable
A varioble is ikea contoiner that stoLeo volueS
which can be acceSSed er changed duing
program run
Ex:-=3
Variable's Component

Idenhity Type Value

")
Idenhity lt re<ers to the obiect address in the
which does not change once it hos been
created
Ex- 3,y=S,z3
jd=161992 Y* = id =l614xX
3

he addrere can be checked using methad id


Cobi).

id Cz) Address of memory locah'on


PAGE NO.
DATE

Tpe (Pata Type):- Data tupe are mean b


cdata and anoociated idenii h,
handle it operahan
DATA TYPES
NumeERS (SEQUENCE S) MAPPING S NoNE
Elnteçer FStrings
Eloahing paint List Dichionars
Complex Tugle
Aoclean
)NumER:
nteac i- Whcle n. without frachen.
} can be
negative
No cinn qiven s
or paihve
"7 No
comma S sed
auumed penhive
) Ex:- 66,
24,-0, |o00 ete..
|loahing point :- Numbe with
4 can be
fracton,
-ve or tue
Nc sigh qiven i
")No coMMQ is wed.
amumed tue
)ldots are hot wc dto clehne flea
point no.
-)
Ex:-6.5, .6,-8.O ,a.17 eto
PAGE NO.

CATE

a Diferense. blw integy and fleahing point.

Bool(Boolean):) lt repreoent the 2 posible olues


True/Floe
eg: 85

)
Complex Num bers i- a His made up sf pairg of real
and imeainaty

xy are neal neand /is= .

print (x. real , X.imag)


a.0 5.0

print (x. real ,x. jmag)


a.0 -5.0
2)SEQVE NCE ! Ao roup ot itemi ultha welld.i
order.
e- shing, Gitt, tuple et
Shing :- A shingii asequence o characker .
be a combinah'on ol
umbol,enolosed in letexs,n, and. ptia
quatahen marls,(n s
) TheceQuctahon marki are
ar not
part of
string
e str =Hello Clus | ste 2="
prlnt (st)
$tr3 24.5
Hello Clos l

EScape Sequence Non qraphic characken


) These arethose character ehich cannot be
from the fkeybeard typed direel
g -Spaceban, Entes,
3) These character are Backsape ek
characte
repreAented by follewed by
nsline
tab chara oter
ist - )t i aseguence itemf separated by a
QCmma and te itemc are enelesed inLJ,
egi-C2, 31,[2,2-5, 4.5) ete
9|4is mutableice changable.
Luple i- )|} iJ o sequence a< items teparated bya
comma and item are enclojed in C)
eg :-(, 2, 3), (2, 2-5,4-5) etk.
-) J+ J m mutoa ble. ie net changasle.

3) MAPPING

|Dichenanyi-4 halds data items in key value poír


ehclese din .
eg i- f|: one, 2:tso't

4)NoNE

This is spe cial daba kype ith sinle waluc. It ii wieda


Siqnih he abiense of yalue
egi- x=5,y= None

You might also like