Page-8

Dictionary

106)Dictionary is a set of _______ elements.
unordered ordered
sorted unsorted
Answer :

107)Dictionary is ______ type of data type.
mutable immutable
ordinary all of these
Answer :

108)Dictionary is also called _______
hash table mapping
associative array all of these
Answer :

109)Which of the following dictionary methods returns keys of the dictionary?
values() keys()
update() items()
Answer :

110)Which of the following dictionary methods creates a dictionary with given keys and common values?
default() update()
fromkeys() values()
Answer :

111)Which of the following dictionary methods will add a key-value pair in the dictionary only if it does not exist?
fromkeys() setdefault()
update() items()
Answer :

112)If no values are specified in fromkeys() method then which of the following values are assigned to the keys?
0 1
null None
Answer :


113)Which of the following methos is used to join two dictionaries?
update() setdefault()
copy() join()
Answer :

114)Which of the following methods can be used to delete element from a dictionary?
pop() del
popitem() all of these
Answer :

115)Which of the methods of a dictionary will raise an error if the key is not there in the dictionary
del pop()
popitem() all of these
Answer :

116)Which of the following statements is correct with respect to the given code?
d={'x' : 10, 'y' : 20}
a dictionary 'd' is created 'x' and 'y' are two keys of the dictionary
10 and 20 are two values of the dictionary all of these
Answer :

117)A dictionary is defined as below-
d={'a':10, 'b':20, 'c':30}
Then what will be printed by print('b' in d)
False True
Error None
Answer :

118)A dictionary is defined as below-
d={'a':10, 'b':20, 'c':30}
Then what will be printed by print(30 in d)
Error None
False True
Answer :

119)Keys of a dictionary must be of ______ type
integer string
mutable immutable
Answer :

120)What will be the output of the following code?
d={'apple':10, 'banana':20, 'orange':30}
print(d[0])
apple 10
Error None
Answer :

This is page:8



Disclaimer: We have taken utmost care to keep the information error free. The site is not responsible for any kind of damage of whatsoever nature.
©Copy right reserved