Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11 views

Python Unit 1

1. Python is an object-oriented programming language where everything is an object. Objects contain data and code to operate on that data. 2. Variables can hold different data types like integers, floats, strings, tuples, dictionaries, and more. Standard data types include numbers, Booleans, and strings. 3. Objects in Python include standard data types, functions, classes, modules, and frames. Frame objects represent code execution and contain objects like global and local namespaces.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Python Unit 1

1. Python is an object-oriented programming language where everything is an object. Objects contain data and code to operate on that data. 2. Variables can hold different data types like integers, floats, strings, tuples, dictionaries, and more. Standard data types include numbers, Booleans, and strings. 3. Objects in Python include standard data types, functions, classes, modules, and frames. Frame objects represent code execution and contain objects like global and local namespaces.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

fyhonobjec

Contained unit Ahal Csmbjnes bah


kec is a se -
Aaldand behuviuy into a sin)e eniy
datd
objet -oiened pgumning language
nlhn ison 0bjedincluhe
vyihan lseakd csdn
AeNhing is in
Mample- An ineger Vavia ble belongs
as ko iis class e he collccirun o vaiious
class. An objecL is
opales on huce daa.
Aua and ncins Ahal
Pruyerie

Bvalue
em h a eprrven ed by an
ubje u
Aae

Phind(a) Jole- to
sbiecy yye inditgie wha) tcind tvalues an
i)4e Gn object can hold.
azlo
Phin (yye Ca) 'in'>

-\tales from all ohe bjecidc)

pinia(a) olP= qa94n

V) 9eiee obec prM we Cun dilete he oreDie)


ob)ect by ung keqund dei
Ly del page
vi)
keycoord del

sondand DaBa yge


Vaiables Can hol vatues,,and
Vodble ane tvem Vaue har

we donu need Fo diine he daatye d he Varia ble


declarimy it. he in pyekr Can auw orn+ialy undeu
whie

e
-4pe o vatue is dainad as do&a
values t4: i
.vAabk an hod he dill4en tyye

a tsiabe, with e
yfe
we can ge) the daa

islandard dta

Numba
-int -tuple
-lso
- Gumyle
Bulean -dicd iun ay
shings
is a de cina
03, -2:32
numbe and
which nain bh Real Aud

) Buoleanype: ryhn buleun type hus ony

nhello,

b-):S
C= 3+2
de lSúv ani"
Pind (a)

Pins (ype(o))
Pins (yye(b)
Pin Cyyc(d)
hon seq ue ncy
as ethe tom
in lip do nà need A be ol Whe sume tye(r )(mulaol)
1)upleO}: 3wt e l0)tleis alss an od l

()
Tuple is wnen wih biacke4)
se43): rs an ungaed collec)jon o dag typ

in key:value Rai)

'g}
S'hn' iani , heigh yulúe

a- [1o'savnt', tbrs)
b(20,abc', s )

d 'nane';lsváni', 'hei,hs
k1nal hy pes
B Tn
obiecd :
) (sde yheco aie elecutable Piece d
byle- Campiled. usually as ye
Ye
hon sune 4hat ane
) BtE
cumplie
Values miny he
are
fsv
afpoit ksv enecubiun by eihe
.such objecs
by eval)BIF
do o contain any ink MaJ(on
Ahamceves
. Coda ohjecs aYe at
egading evesy uwe-delinecd uncun 2 al of which
Cant5
Ahe hearl o4 enecusin
do contin ssme
tnyveu)jun)
inpul "enHr
expY e val (
enkrepro)n (04203hou
ol!

Srame Gbject execudin sack ane io )


objecs veesenng
These ae inxiek,
yhon 4he yhon
cunAan all he inhmon enDunmni
Frama obecks 1unine
enecain
a
neds to encw duity previd)rack trme
inclade alinc 45
*Some o ils oibuley beiny enecbed
that
The Goo object
9loba\ tatt name spacey
-dicturiovie br he local
- cuiren inwdin
dnd 61
in a new tame obje
Cach funcrJn cat esul oead as wel(
each fume obfet a Cseeck ume i)
access a hung ob)ecs is na \yaebock
Ce whevc you Can
3)Yacebact objecd an ewcep}n
pyhon (
evwr in
make an
when qou ma the inti4er eb
aie no cough o "hande olpsha
*T exCOpliunk infoouin simitay t e
he
diagnuic
wh ssme (innomui lust
bele
Tuce uck
ileu line N?in R??

exep)iun and r's creued whon


o dn
Stack 4Yacc nma\un pruvilec or un excee)
i! a hundllert)
an encepBiun occur) d Jhe fruce back objed.
ghven access
-iun,his handley (s

objeclb ane ciea kd winy Ahe pyshun eutended dhy


slicc
syntax allow) r dietns pes ol sndeni
synla. his enkadad
indoving inrkde shide indaity, ubi-d
4hee voniaw types o} pe.
he eltips
ni tonal indening rand indeuing using
The
sequene.,sal:
endii slaw'end], or uwny he ei3)
sic ojec) Cun alb be geheased by e slie) Bl4
endi].
·>>>Joosy 'obcde'

->>>hosr [:-2) o|P eca'

clipsis objects ave used in enenced slice nodaion


asdomon kd. above
sed tveyreeent he acdual elliyçes in
hese ob ecds ave
(..)
syntend
NONe, ellipss obiecB s dve have a singe
objecs
.L`ke ll ue set Value
have a boslen
clips'sand

olP Null

s)xeange dbjec
XQnget)ia siblin, GL
ccased by he B0E
.XeON% objecds ane is limied and when unye)
bed whon memoy
he ungec) 8lF,
unuasually (aye daa set
qeheu* dn

pinsCx)

Rhon oreMdors on vaniables gd


qnd
pertYm 0Peradrons
OpeYakors ove Used
Value
al
spcci symbls.
opevatovs:ane the

Comparison
l9al opendors
V) BiBise oferaors
ud to pekssm mallemaial opeution hila
These are divoion
wbucisn maliplaUn ,and
addin,

o pevun do X-4
- ’ s u btyacin o
*’Muiylicaltun ol openndb y

he secsnd 6peYand yestylt as

value
YOuL as ineger
ofo ’ Modules

b 20
Pin ("addAiun is",atb)
a-b)

pin (oviban is, alb)


at*b)
Comparibiin opeaton
vaues.id eihoy deunnsTue
Compaves he
b he cordi)Con.
aceoxding
Desripy
ha
(omeae shan'1ue il >y

vgh
than,1rue i the
Less

oeland are
Equal 4 quei!

6meaei thun or equcq| to !


less han ov egelto

b-0
(ess hkn b:"acb)
Pint (a
asb)
pins c"a qreqr han b

Condii6nd saMmnlsb
(ombine
and lo4ical AO:14e bh e ahundNandy
opeun
(6gical oR ue i ebher o he

oyenen is falk
iogi al wo:Due i? he

pin (acb and asb)


hin (a>b oy acb)
prin C no (b and asb)
iyAsstqnnen opensso
Used to
Destyp4un
OReva
vaueod vgh sse
Assign
nighJde poend wth
Add AND: add t5 le!F
le opevand and Yhen asnyn
operd. S u b u n p a-h l
Subhucl AND:
o a=b a-tb
Mulbily AvD al-b a-alb
Dvide AND
Enponen AND
**
MOdulus AND
a b aatb
al=b a alb
pobim biise oR
ab
as>b

v) B)wie opet

hoe avc wed Brae on biay nmbfs


jescsn
Bìwe AND
Bi wjse NOT
B e XOR

7 Bitwie te

aas
bob
Pintlagb)
i lalb)

idenal
CaYe no)

b=0
b)
Pins (a is no
nin (a is b)
slandad Bi!-inkncltun
kfined as the
Lndion hse ncinaliy pe- dehned in pythun he
inkip1tltr hus seveval dundions Ahet are dleaus
yhon knun as B}-i9
These Runcions qe
resen foY use.
inpyh.
kuncdiuns,hoye are sevenal uiH -in Ancions
he given objed he
h soten
()
) intC):nid
phin (*=,x)
AIns(hom prqamminy language")

ole
gphon pqiumning langge

2) ko () lenc) Lancdren i used to ve inn he lengh

Sravani'

DiN(ien(A)e

ol!: coass 'lis'>


ge an. in)
4) Ingu )_: used Ao ge an
= inpu (iEny a vau
val
pin ("you entrli va)
olr enlr a value

s) 1á maei hunelionens an immuabe seq uene


il

ends ax a sei Jied numbe


puin(Bs

Cor l,23
to qel the sym uf number) d an ileae
\aum ): used
lis S= sum (Ci,2/4])
Pins(9)

dbost)huncliun s wed to retnn tha abisyk alue


d

A -20
in (absCA))

20

) Und )i yOMnds ol) ha dg o! a num bei and nenn


laasing pin hambt,
he
Pint(uund (lo p))

snglle) elenenA
qe the
A- nin s213))

an inegrn ale
in); uotd do ge)
B nCo 2)
and many m

loa(), oPenc) ec.


helpo s 0

) chareeier ype Ccha):


no chaactr ye, in Bh
in Ryhin yure is nepresendby
lenyh ohe, i i
chaucer sriny of
a shing
class slY
)puint
TnCand c++ a pint is a vinig ble +hat hulds a
Points
memy address bul cue dont have any kind o
Py>hon. u uan adina adeo any obiect
In
idc?ncio
Yhen you need fo use iacncin

pin (id ca)

ohy ind and shu+in:


3)
Se inkyer oalucs ard
dua ye and
shovd si3e incr alue ong Suuy
hon dce don' kgbe
in! dasa tye lo)
hvn f bih long in) gnd
ng in and sho in jn
shs s2e inlgeo
dauble
4)
da ye
phon dino) sphd doudetyp. Tn yhon ev eveo

you Cqn we Ploq day


alues
L long s12e f\va c's double daba
Iluat is achally

Numbes
6inwduciton to Numbeis
used t sore h nuneic
numbtt c Ayps ave
The Numbe obecds ane eard ihen
yúriabe.
vues inside He
Variabe.
Some Va|ue is assigned o a

He relrene a numbe,
w. to dele)e
hon also allaw
keynd -Eg: del a ing
b using the del
numbe
yhon here dre Ahiee tyges
n
wibh no deciy
nonegutic numbh she
are the -Ve
yhon. Houever
on intqer in
olim! on he memor
Poinl. There is Conshamecl by he ampunt
ntqer is
spe ol ha
Ous synm has
unlimixd leng)h.
ha deimals o

type (n)
Rsin numbey)
store he docimal pin)
ve is used to
The loa)) Ayye
{latng in nmhw.numh.

Pins(ypeo)
ol?
cclass-loas'

3 compl Numbeo
ave od he tom at bí whor a i
Complen nymbers
and bj is he imaghary un)
num bev
he veal part o the
nhing bt Fi.
o) she numbtr:he imagnag
a= 2+3j ar 2+3J

(a)
pin (kupeca) pin (a: img) ol: t¬
243j
cclass ompler's 3)

be neqave whith cun soe in a


o umbNS Cun as
(eg num= -423.3)J
cnishnJic oyha) tun winy nmbtrs in pyNN
peudmng
sinple und easy to ondenand..
is

seCejve the olp aan neger wt ue


poin! yalue
( ping (lo/)

3333 2
o)e
3 pber odanam bea do u
nape the
1yuw wan
wan
asserdks (*)
erain value ie dubl
use

emainclor insyd
want to qed the (o)
opeaor
yo Modulo
in Cae he
quolienk,use
she (hmi/"numg)
o!ping
hon
snvesion in
c
type
eSP the tveolp
qbs():3 g)

"sqy}):The sive
3scquences veyeom
by types hat
cakgy iems canlae accesl
ens Theee
odred colletion o
s o încow on he seguente
by fheit Ausion Ayyeu hat an he
proides sevei-bill-in gequente
Pyahon cálecdiun da.
pula)c
Used to store ond mani

sthing
2)list
)T4ple
) Ranqe
in single (
encloed in
chaaces
qie ctquenco of
(anst
siMmutabk , Meanigy Jin
They ove modised abr
cveu
be (atnan ond
iclucy sicing , Con
opeusjen
* Shing meshds
Varisw sm
a 'Savuni"

2Slist
- Lit is a
They ae maqble Cammas ad ehcloed
ems ae sepera\ed by
-hese
squane ()
backes atpendiy
io a slicig i ineleing,
opin inctacl
i

in (ac2)
Pön) (a¬: ) (213143

Point(a)
[o,
r3igps)6a7,9]
(s)) (1ana 132
Sntrstof specityiy
yhe
atvs steP
'unn.
ange -hep
nepotns type
sequen mutable im an Rang 4)
co
2D
(alD Prin
(at) pins
ope uPle -
sclony ininy ude int iu)ins
imilar ast TUples
annot
be bu) 0) hesis
to Puven
bob o
by
loed enc and(ommas Thus
immutuble art qms
areTUPles
les TUP
Naing Me did coln a
peents a
di' ve
-The aping aype knownas diJnan'es
value puis rals dlouiny guÀ
and muabe r
Dicinaries are
unordlered
daa usirg key S
velrieve
ue and
didionay mw he untque
ina
Person-"nome".'iohn' "'aqe": cy

in (RIn)
['nanw'])
pin ( Pe san "Engineey"
in]
cCupaL =
peson C"o
Phin Cpoun)
30,cyeutyor }
4'and: jhn 'age'

\otupuin'enyjne'

anolved calecdin o< ungue eltngn


-se ae
Gn be adcder or yenw
- seds are
muab and eleNeNs
sls
- DupliataN ave aukmutically vemved fn

- o Si add(olemen)
S-upda)kse)
-Svemove ( elemend)
(my) ogenses x:
mgthb no
upda
le add Iile
tor nemove
in
sonhvzenst)
(ienebe)
uiy B
Ysenstl
Zundin bi} in )
elemynt he
sed fugen he o
ame eMajn
he elemens uhk "
becan set a of
e any amodifi o3 "
an is set
sel ve'soun immabe
(s) in
()uldase S"
s-t213
(s) S4m -
Min) -
-
¬lea, S .
()
eemenjsdisaid(

You might also like