Revision Worksheet Class Xi

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

REVISION WORKSHEET CLASS XI

CHAPTER- LIST AND DICTIONARY

1. Start with the list[8,9,10]. Do the following using list functions


(a) Set the second entry (index 1) to 17
(b) Add 4, 5 and 6 to the end of the list.
(c) Remove the first entry from the list.
(d) Sort the list.
(e) Double the list.
(f) Insert 25 at index 3
ANS-(a) list[1]=17
(b) list.append(4)
list.append(5)
list.append(6)
(c) list.pop(0)
(d) list.sort()
(e) list=list*2
(f) list.insert(3,25)

2.

3. The record of STUDENT (Name, GRADE, MARKS IN 3 SUBJECTS and PERCENTAGE) is


stored in the following list:
L=[‘Amit’, ‘A’, [35,42,85],98]
Write Python statements to retrieve the following information from the list STUDENT:
i) Print the sale of 2nd SUBJECT.-
ANS- PRINT L[2][1]
ii) Add 56 as MARKS IN 4 TH SUBJECT.
ANS- L[2][3]=56
iii) Change value of product from “A” to “B”
ANS- L[1]=”B”
iv) Delete Commission from the list
ANS-l.pop()
v) Print minimum marks scored in 3 subjects
Ans- min(l[2])
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 Non-Zero Elements of L.

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))

Q.1 How are dictionaries different from Lists?


Ans: The dictionary is similar to lists in the sense that it is also a collection of data-items but it is

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

Q3Given dictionary d, print the value of key 10

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

You might also like