You are on page 1of 2

KENDRIYA VIDYALAYA TAMULPUR

CLASS XI COMPUTER SCIENCE


PERIODIC TEST - 2 EXAMINATION 2022-23
Time Duration: 90 minutes Maximum Marks: 40
----------------------------------------------------------------------------------------------------------------------------------
General Instructions
1. Attempt all questions. All questions are compulsory.
1. tp=(10, 20, "gold", 30, 9.5, 'silver', [15,16], (9,7), 50, 100, 75) 5
Consider the above tuple ‘tp’ and answer the following questions:
i) len( tp )
ii) tp[ : 6 ]
iii) tp[ -8 : -4 ]
iv) tp[ 5 : ]
v) tp.index( 20 )
2. Write the output of the following statements 5
i) >>> tuple("COMPUTER")
ii) >>> tuple([10,30,60])
iii) >>>("star",)*3
iv) >>> max(234,567,890,210)
v) >>> min(50,90,20,80,100)

3. What is the difference between tuple and dictionary? Explain 2

4. Write a Python program to input ‘n’ names and phone numbers to store it in a dictionary and print 3
phone number of a particular name.

5. Write a Python program using dictionary to convert a number entered by the user into its 3
corresponding number in words. For example, if the input is 678, then the output should be 'Six
Seven Eight'

6. Write the output of the following 2


a) t1 = ('a', 'b') (b) a = ("Anita","What","are","you","doing")
t2 = (11, 22, 33) for i in range(len(a)):
print(t2 + t1) if (a[i]=="you"):
print(a[i+1])

7. Write statements for the following 5


i) To create an empty tuple T1
ii) To create a tuple T1 with first five even numbers
iii) To convert list L1 = [55,66,77,88] to tuple T1
iv) To create tuple T2 with the following data
"Bus", "Source", "Destination"
v) To print 30 from the given tuple
A = ("School",[1,2,3,4],(10,20,30,40), "Ninety"

8. Write the output of the following code 5


(i) d1={1:10,2:20,3:30,4:40,5:50}
print(d1.items())
print(d1.keys())
print(d1.values())

(ii) d1={1:10,2:20,3:30,4:40}
d2={5:50,6:60,7:70}
1
d1.update(d2)
print(d1)

(iii) d1={1:10,2:20,3:30,4:40,5:50,6:60,7:70}
del d1[3]
print(d1)

(iv) d1={1:10,2:20,3:30,4:40,5:50,6:60,7:70}
d1.pop(5)
print(d1)

(v) d1={1:10,2:20,3:30,4:40,5:50,6:60,7:70}
d1[6]=65
d1[8]=35
print(d1)
print(len(d1))

9. Select and write most appropriate option from the four given options. 10
(i) Which of the following functions will return the key,value pairs of a dictionary
(a) keys() (b) values() (c) items() (d) all of these

(ii) Which of the following can be used to delete item(s) from a dictionary?
(a) del (b) get() (c) getitem() (d) all of these

(iii) What will be the result of the following code?


d1={"abc":5, "def":6, "ghi":7}
print(d1[0])
(a) abc (b) 5 (c) {"abc":5} (d) Error

(iv) Which of the following is correct with respect to the given python code?
d = { "tiger" : 12, "leopard" : 6 }
(a) a dictionary d is created
(b) tiger and leopard are the keys of dictionary d
(c) 12 and 6 are the values of dictionary d
(d) All of these

(v) Keys of dictionary must be


(a) Similar (b) Unique
(c) Can be similar or unique (d) All of these
(vi) if tup = (20,30,40,50), which of the following is incorrect?
(a) print(tup[3]) (b) tup[2] = 56
(c) print(max(tup)) (d) print(len(tup))

(vii) Which function returns the number of elements in a tuple?


(a) len() (b) max() (c) min() (d) count()

(viii) Which one of the following is correct to insert a single element in a tuple?
(a) T=4 (b) T = (4) (c) T = (4,) (d) T=[4,]

(ix) What will be the output


D1 = {"Sohan" : 75, "Mohan" : 92, "Rohan" : 54}
print("mohan" in D1)
(a) True (b) False (c) No output (d) Error

(x) Which of the following is a Python tuple?


(a) [1, 2, 3] (b) (1, 2, 3) (c) {1, 2, 3} (d) {}

You might also like