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

Unit-3 Python Part-1

1. The document discusses lists and their properties in Python. Lists can contain multiple data types and their elements can be accessed by index. Lists are mutable, meaning their elements can be modified in place. 2. Common list methods include append() to add an element, pop() to remove an element, insert() to add an element at a specific index, and remove() to remove an element with a particular value. 3. Lists can be iterated over using a for loop. The length of a list can be obtained using len(). Slicing allows accessing a subset of list elements between specified indices.

Uploaded by

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

Unit-3 Python Part-1

1. The document discusses lists and their properties in Python. Lists can contain multiple data types and their elements can be accessed by index. Lists are mutable, meaning their elements can be modified in place. 2. Common list methods include append() to add an element, pop() to remove an element, insert() to add an element at a specific index, and remove() to remove an element with a particular value. 3. Lists can be iterated over using a for loop. The length of a list can be obtained using len(). Slicing allows accessing a subset of list elements between specified indices.

Uploaded by

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

UNIT 3

UNIT 3
Lectur notcs

ucto totes dus orgmeuti.

pecties

duppant deyueutct to o9c mutple vos to


SecueneS?
hnoove Thc

w a cOtectn cacsQ ctc data. It u atso caled QJ choactcn


Sisting ig
Fn-8= iout (Eatas Thc

pstiht(tyoct s))

w:he(eo

yalucs.

petint (MÍiJ)

30
dànila to Qist (tent hat ot es emrtabe . NO
Tknlt;- Tunlt dhanges are
Y:( to,Jo, 30)
pint{"The numbcNS in n Tupte:")

p9tint fx fi3)
30

irtable deyeutC,hl,no chaugs 09te aloed.

b'io0

vie'. ustd to pouide a buttsn fo

(o00000)
et OxOSCFPCCo>
ptta.data)

Pouge objet:- Yaug t9 fucten w s8cs to Cacorte a lage ojet. Gieneroly


to uaitan The auge value. en emurae ejueutc
ut u ured in Qoo

prht Ci)
0UG1Gble in nthon
Lohich (an be n9tteo as o Como- tpaYoted otues (iternt) bhcen

Squore brat ra.

troty Ovcg .

irden.

ostbity dky.

St2= , 2,2,4, S,6, ),


p9tint ("ilo:

Oundctig
die = ('phyi', 'chentry 1944, 2q0oJ;
rrnt ( Uolye aOOlabe at inden 2:")
pint(sin{2])

ptot (he vo use aucitc tse at tndez 2:")


psint (sie [:3)
(a4,2001];

let ands,
atnt (*ottn detetihg Vatuc
Valuc ot index 2:")
ptint

cttan deleting vovclue t inder 2:

Redut
3
Jugin
Ien,2,31) Goncoctauatn
,2,3,+,S)
hepetttn
('HHi'H!,'J
rtemberdkap
3 jn fu,) Dtrato
5,6,1n) C,8,
,5,4]
now isru
dite tista C,3,S, list
mutae Lists
(+2) slr
3[,o, -= (o,
o)) ct(range
(o,to)= onge
2,
·[o,),
*k,-)
j-) i,k) range Ex:
ond Peneh Bull-în
toncins
its.alando)- ented sits by a kingle valev
litd ertend laccke) extend lit by adt
yaluy
istd.renmove (e) -
revnu(- teveu l in place

Jrindax (u) - fird aslnot povitbin tx inl


3

’pnud)
Extudl)
I H)

>pemovc()
-’Rrucrs)

S>>1.0npend(1o
s>s del(x13)

Dh:-,s,8, 4,10
Olp:-1s,8,6]
(3) Entcud:- Cnscud e ttyueuce to a iat ) n t -
>n: f, 2, 3,4]
>>>0. inscat(2 (D)
»-344,J >>>
Ofp-l,2, o, +,6, 4)
olp:- ít, 2, 3, 4, 3,4,9,
>>>=9?,10, ,6)
Ss> 7=(, 2, l0, 4, G, +)

f, 2,10,,)

SS 1=(!, 33, 2,1o,4, 4]


Ss> 1.ove (33)

Ch-t,2, t0,+, )
order

>s>K =(2,c, S,, 3, 2, )

EcKo toop

a
Lt Cung-h oydegn to @eceas frutor ie

ticps.
3 poromt ae urd Gort, top aud

L(Hort: top : ApJ


tnd

be
end
Hort
ite k1h egothe ina

b d
2 6

pint(L(2:-s)

fotnt(ot (2:2!])

Th

bw

end'

palnt(L0:3)) poht (LtG:)


Reues a ruurhinle

L ('a','b', 'c 'd'e]


Priat ( : : -J)
op' 'o. !,2,.3, 'c)

lenlore httint ctemat tn

L:J= ", 2, 3)
print (L)
olp' a',,2,3, 'c,'a 'e)

u rscurt in The
rtd to ueet it an ctement

tt inthotzing
Jis =l, 4,3, '2, S)

otth volue ")


Éng ele hneut

etemeut wTh value e)

Gotirg

Wenut wh Value
a (1y:J
adude

33 4sr
o 93

8399
23

Oh-alo:9:2]

It,22,3), ue, ss, 66


( ) a lo:4) lo,

ota: 2;-7
-9 -8

3 6 8
a f: :] fo,", 22, 33, 4e, s5, G]
-(55,66, tt, 83, 9)
af5:-1) =|99, 88, S9, 66|

af-t:5 :-(99,80, 59, 66

3 4

pstnt L(2] 'ce! ldd',['ece',

3/
dd
int (l -3)) - ('ee! dd [tte tat1

'ect

cloug

LU J 0
rstin(e)
0/int a, fby,o],d

LJ. appcnd C )
ptint (L )

interti L3. inCrt (o, !xx)

L J. ert hd (l, 2,2] )


pon ('a, 'bb', 'ce,'dda'],)
7:tli-pop()
casco1 (nmote (ireul) han moting a ay
oioes don't mattco becau he dato

Land t o -

(Oheneuca ne Uaniobcs votue ds


liosing Rapens
Uatlable

G a -[81, 82, 83]


b8, 82, 83)
fatre
p9tint (a = b)
ptint (a b)
b a [s,82, 83)
ad b.
podnt(a =b)
ptiot(a b) Nade UfTh One aiar arttect
e a0a sta.

potint (a)
Okirmut fatrrtut b-g.

Conina i - wc want fo
e neeol

to cuoid ne

a coneatr a

Carr The üe kap0ensro Or lyt 4 The lote ih.


E a (8, 6),83)
b:af] t nate a core (thg
potint (a: b) Fot8c
pstint (o ub) l6, 22,83 )
blo) =5 S,82,8 3)
psint 0)
0J We e1e re to malte clonges to b otto
p9tint (b)

BLut -n- Flutt he qhon intcorctr


ad ype built
Qbul)aiolte int)
inut) root)
booll)
noitt)

Auopl )
Tousel)
locdt)

PLoteying

30.

total o
(lae. in nentCS:
ton
total t \wae
etota )
The etemu
potint ( The tortat o
dores =(3.5, ).2, . 5, 0,5. 2]
Hotat O.0

total t= (atue

= fotat | lentto)
ctIerage )

naint )
olp-53

do a cuuuctba
& det natat:
to
umeers -[2, 4, 6, 8, total (rertr))

totai (uclue- lit):


det get
Hotal o

r m total
Olh' 30.

c din ():

rauge(o,1o) :
cfosti in Qist.appndli)

potine (a) o to,,,3, 4, I, 4, 4, 3,9 )


e Cond elema coleem

Golen
pnt (olo1)

brato)
psAint b)
puntlofo(23)

Ait (o)
pAint(b)

potint (oto)
ponint (b)

COcutc =I
T,,3),(4,s,4)
(I, , )
rauigr( 3) :
nOcO. onperd (0oustce )

table appoud(Do)
otit fabte )

ofn'- f , 3, 3), &, s, J


Nested Lit a
main

Can

nabix centai m Ynu audn


Called

maf
Y in mat: daplaye elintit
Yow by row
[L,33,
[y,s,63,
But te oa
e ach ow; hevec
anothea a loop inide
ad
foroop
in ma

Pit)

3ongellelmat)):
io onge ( Lan(mall:1)):
P t(,malilR,eudo)
List Compre hau iA
list compe hsusiovd 2oet he ation d M3o isty
st , top,
dectonay d aange) hat satuty giuen condteon
3 Containd vey Compact code bAualy a

Cse ate a with sguansi inteqeu fran


cmphy st
Square =[]

2) # add cpuas
Squauarap pevd (x t *
as
Can dye scestten
Sqharey x**a tor x in Yonge (1,11)

Synday
hem in
Lexpoeion
in teableg if stm
for tem

Colains elati
expremon- aceddng
Staledo
Exa3 X = lo, 20, 3o]

Hos sin y
Jat appeud (ieD
22, 32y 3,32, 33,34
toutet C",2, 13, IY, 21,
it Compoeheim fo algove erampe
ut i+5 fori in
in X
-TúplcJ d tupe w a coetibn'o hich e 09dere d

3&nposts at orotio fon esentes


’ I t a l , hut merben olbjet
a sin fuoutdn't uuge , ure a ipte fo prevent
Odded, chaged oyM deletcd.
-7üner are OSe etuent Thon dit due to grons inplemauttl
& f u , S, cc,9J

Olp' (G,S, 66, 9)

dome The orcrctbn iple are:


o Th indo no. tnide syor
- dccess le Hems:
bxattt

n=('o"b', 'c,'q'
nnt (7(3)

Tunles ae udaauabie.
K-(8,5,a,', )

Value 9 a tunle csng


a unle Je Cn koop Th vatucd 4 eop.

p9tint (i ) aa
Sorcted voie Orcerxt in a

X: (!, 3, 3,4, S, , o, 2, ,2, 2)

olp-4
dog a Speried vaue aud esnu he
ound.
poin 4 cohee it coas
12, 2)
= (, 2, 9,4, S,6, R, t0,2, 4,
M, inden()

(enl .

(,2, 3, 4, S, 6, , lo, 2,!, 2, 2)


X=

print y)
olp'-12

Tunle

tosteg tn tupes

(3)operot ite incotibn a delct Elementt can bc Qtcened bett


ae beteg peetoned.
COnume!

Doe! not Raue


Tugls
Pyhon Begunce
tlamsuta &tHem pls
o
mut alle. So We
Cannot modity
elomaut Once tope cteat.d
top = ()
tupr =lo,) topla coith one elomsut can
te creaed along th Cona
top (to, 20, -30-1, 4os, tydeasad")
tupy (0, 20, B0 no byaces
we do not Ue

lople cud not a d'& hy otten

we Can oreate ieple doom a

-tel- toplo(I8) convet ot to tople


psint l +pl)
lamauts
Aceemng o t0)
up (so, b0,
Print (toplo') # so dizplays
piat ( tup ) to0
piat (top[: ) # dulay. all elwsut
shudant o(to, 'dip', so, bo, 9o)
shudant fo:]
priat (yno) t io

Basc opoatou on

dan(studet)
vCan vepcat tope
feas (aSo00 - 0o,) y
Prnt(fees)
(So00,o0, S000.0, 2000- 0, 26000.0)
VCan Concaleho te

stuint = student +fees


piat (studant a)
VHembethip în tople

raí"

You might also like