Revision Worksheet Class Xi
Revision Worksheet Class Xi
Revision Worksheet Class Xi
2.
l=[12,4,0,11,0,56]
l1=[]
for i in range(len(l)):
if l[i]==0:
l1.append(i)
print(l1)
Q Given L is the list of elements l=[12,4,0,11,0,56] ,create another list L1 such that it stores the indices
of all even no.
Ans
l=[12,4,0,11,0,56]
l1=[]
for i in range(len(l)):
if l[i]%2==0:
l1.append(i)
print(l1)
Q(a) Write a program to search for an element[4] in a given list of numbers and print
its index value. Given l=[12,4,0,11,0,56]
l=[12,4,0,11,0,56]
l1=[]
for i in l:
if i==4:
print(l.index(i))
different from lists in the sense that lists are sequential collections(ordered) and dictionaries
are non-sequential collections(unordered).Elements in lists or tuples can be accessed by using
indexes. But in dictionaries the values can beobtained using keys. By changing the sequence of
key we can shuffle the order of elements ofdictionary while this thing is not possible in list.
Q2
d={10:100,20:200,30:300,40:400}
print(d[10])
Q4. Given dictionary d={10:100,20:200,30:300,40:400}
a)change 100 to 1000
ans-d[10]=1000
b)delete key 40
Ans-d.pop(40)
c)to add 50:500 to dictionary
ans-d[50]=500