Professional Documents
Culture Documents
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'
(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
(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
(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,]