XI_CS_PT2_2021-22
XI_CS_PT2_2021-22
Section -A
Each question carries 2 marks
1. TypeError occurs while statement 2 is running.Give reason. How can it be corrected?
>>> tuple1 = (5) #statement 1
>>> len(tuple1) #statement 2
2. Write 2 mutable and 2 immutable datatypes
3. Consider the following list myList. What will be the elements of myList after the following two
operations:
myList = [10,20,30,40]
i. myList.append([50,60])
ii. myList.extend([80,90])
4. What will be the output of the following code segment:2m
myList = [1,2,3,4,5,6,7,8,9,10]
for i in range(0,len(myList)):
if i%2 == 0:
print(myList[i])
5. Differentiate between Tuple and Dictionary.
6. d1={1:10,2:20,3:30,4:40,5:50,6:60,7:70}
d1.get (6)
d1 [6] =65
d1 [7] =35
print (d1)
d1.clear ()
print (d1)
7. What does each of the following expressions evaluate to? Suppose T is tuple containing:
(“These”,[“are”,”a”,”few”,”words”],”that”,”we”,”will”,
”use”)
a) T[1][0::2]
b) T[2][2] in T[1]
c) T[:1]+T[1]
d) T[2::2]
OR
State True or False:
a)In python ,a dictionary can have two same keys with different values.
b)The value of dictionary can be accessed with the help of indices.
Section – B
Each question carries 3 marks
8. Program to find mean of numeric values stored in a list.
OR
a) …………method is used to delete elements from a list if index is not known.
b) Tuples are………., you cannot update or edit the tuples.
c) Differentiate between remove() and pop()
9. Input a tuple of elements, search for min and max element in the tuple
10. Program of linear search on list of numbers.
Section C
Each question carries 4 marks
11. Start with the list[8,9,10]. Do the following using list functions
(a) Set the second entry to 17
(b) Add 4, 5 and 6 to the end of the list.
(c) Remove the first entry from the list.
(d) Double the list.
Display list at each step
12. Consider the following dictionary stateCapital:
stateCapital = {"AndhraPradesh":"Hyderabad","Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}
Find the output of the following statements:
i. print(stateCapital.get("Bihar"))
ii. print(stateCapital.keys())
iii. print(stateCapital.values())
iv. print(stateCapital.pop(“Bihar”))
v. print(len(stateCapital))
vi print("Maharashtra" in stateCapital)
vii. print(stateCapital.get("Assam"))
viii. del stateCapital["Rajasthan"]
print(stateCapital)
OR