0 ratings0% found this document useful (0 votes) 31 views6 pagesClass 11 CS Lists
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
CUASS= 11
CHAPTER © 4 ay S_
List! Ordered Bequance sohtcth Ip mudable .
can be chuaged
after creation,
Example:
digt= (2,4, 63,10]
0.0 22 4 SS enclored in
Pywore reuters [
Accening elem
raat) — <
print(apal-1.) ——7
"a Tadexing Ky
Mutable — 7?
L contents of in be changed ee Is ertabed,
_ [Red “Cayeesl “Blue” ] Qutpud
t
Liste =
print oo — > bareen
f nge” .
ne a a [Red “Orongs’, 4 Blus"}
1
eames Cronged.
(0) Cncaten nt Ton two or more Lab (+)
Spth = C12,3] Oulu
Ustz= (45, 6) {1,2,3,4.5, 6)
pri (Gat 4 Sint 2)
For NOTES AND LECTURES, Search NITIN PALIWAL on YouTubeOepetition + Replteae o tisk (%)' — Qupul
Lith = ['Maharethi J] [iMahavathi, “Mohothi”]
pring (1int #2’) :
@Membeghip? Cheds if the elumint Jn present Usk,
Lipt = ["Haon” , “Bhyii”, ee ual
print (" Haan” 4 Wath)
print (" al in me
@, siting 3
oe Ceca", area “SS ‘On sid te “Orarge")
pans sta (2:4)
ped (Aint 1 [ (3: 10} - - he ‘Pope )
pris Cage 1 422)) ae
pried (att [ Of ee “rreen’ ]
prin (Hint a (6: 422J) . [Red "Ble"
wnt ai 8 Ppt eng")
proniat ug: ¢ [farpe”, “Orange”
KS es |
“TRAVE A
Ly Aceemi Stem dino Lal sequenKelly,
tt for Loop; Output:
sist = ["Hoan", “Bhyii” , “Maharedtiyo'] Bhs
for i in Wist1* Mahorathlyo
prmé (3)
For NOTES AND LECTURES, Search NITIN PALIWAL on YouTubeHF hile Loop!
Sik = [‘Heen’, “Bhyi?” , “Maharattiye')
+= 0
while 1< ten (aL) *
prime Aint (1)
t+
List Methods & Built-in Fun chiens
( gen () + reherny, Segth of the Mat
@Lsel) > creates on empty tist
®oge end()~ appends Bing clement,
© extend) opp ensls each elemondin
@ingert ()-rinsert af emank/ oh ,
partivdor hades
Ocountl) + returrdy.n0 of Hes
Seemed oppor,
@inden()+ chant index a, the
™ ocuence
Qremovel)* Removes given elumud
Ouspul >
Haan
Bh yi
Meherathiye
Oespod
Watr= [1020/30]
prin (en (tntd),) e3
Sint L=Aigtl) Uj
print ligt)
(lo, 20,30, 50]
Wak Be LioAo.24
List. op nd (50
prtnar(nst 1)
List t= (10,20, 30]
Wxt2 = (40, 50]
Uist. tebend (liste)
print Cligtz)
{t0,20,30, 40, 50)
dist = (60, 20,30]
Unt. ingest (2,25)
pring ((i5E1)
Aipk 1 = [10,20,30, 10]
Ligt1 court (0)
[10 ,20, 25]
Kpt1 = [10, 20, 30, 20] L
pried (ih sindex (20))
Lat1= [to.20, 30 J
Aistl . remove (30)
pring (tpt)
[10,20]
For NOTES AND LECTURES, Search NITIN PALIWAL on YouTube@® opty rehuns the elemunt ond abo, Watt [l0,20,20,40]
Hemover from Itt PRE (listL-pop(2)) 40
print (lig #2) [10,2.0,30)
(revere reheves the order, Matd= [10, 20,30, 40]
(gt2.revenne ()
pring (I7s41) 0,302.0, 10)
(sort)+ sorts the clemed, ligt 1=["Cal, “Ball? 20 [esl tah”
tigh.sort U Zebra")
pemd (4'p1)
lista = C2 rwRe
Mata. sork() [299/125]
perl Und
@ sorkd (> 80+ ond Mpta = (23, 95997, 64)
aeangt Up PB sorted( (intl)
priakiatt) (23,45, 0,64)
nnd Ultat2) L203, 45/60
=L1,20,30,40)
6 mn f miin( list)) 10
met U) rink (max list2)) 4o
suml) \N pret (Suen (ist) too
lesTED List — lip} Inside Itz}.
ee Outpus_
Mipba = C1,2,'0°,'c°, [69,91, 4,9 ri
pri (Uat 4.043 (0})
For NOTES AND LECTURES, Search NITIN PALIWAL on YouTubeO fin
Suggestel progroma
4 the Maximum in a lists
a= UL)
List size «int (Inpud ("Enter size of Usk")
for iin range (list size J:
val = int Cine uk ("Enter "))
OQ. append (vol) 6 rinds irimory 1 ist
Max = ao] iat eis - Ore
for jin range (lipt. size):
H(A Ci] > max)? .
mane afi]
Lipid \
PC Mox Aumber B 2” max.)
@ Finding the mean in a dist: \Y Onkpat
bist = 01
Size= fatCinpul (No. of *y No oF elunenk % 3
Enter) 95
for 7 in range Cstz—)é 3
ists a ( kei
si oO fre Se 43, 335333355 35333
um =
for i in
oom += hipe C7]
pent (sum / Size
Poogram +o a numbts in a dist >
a=(1
She = ink Cinput ("Enter she of the Sst "))
for sm vange C sue) 4
Vat = int Cink ("enter Number >")
a. append val)
Key = im Cingu(" enter number to search ; "))
fiag = 0
For NOTES AND LECTURES, Search NITIN PALIWAL on YouTubefox i im vange (sre):
if (a Gi == Key ) 2
flog = |
pos = i+]
break,
TE (flag =="):
Pint ("Element found at 2, POs; " position ,")
ese:
pant (" Element not found )
© Frogram 4o comt Frequacy of a ws
a= CJ
Sizes intCinpub ("Enter stze of the (i ay
for {im rang (size)!
vals = ink input ("Enter —
a. append (vas)
Key =tak(input(“Enter ni SS Frequsn
Count = 0 XR
for 4 in range (si
For NOTES AND LECTURES, Search NITIN PALIWAL on YouTube