#Ans. b
#Ans. a
#Ans. c
#Ans. a
#Ans. d
#Ans. a
#Ans. d
#Ans. a
#Ans. b.
#Ans. d
#Ans. c
#Ans. b
#Ans. a
#Ans. b
#Answer: d Explanation: Dictionaries are created by specifying keys and values.
#Answer: b Explanation: Dictionaries appear in the form of keys and values.
#Answer: a Explanation: In can be used to check if the key is int dictionary.
#Answer: b Explanation: If d2 was initialized as d2 = d1 the answer would be true.
#Answer: c Explanation: Arithmetic > operator cannot be used with dictionaries.
#Answer: a Explanation: Execute in the shell to verify.
#Answer: c Explanation: Execute in the shell to verify.
#Answer: b Explanation: Execute in the shell to verify.
#Answer: a Explanation: The output of the code shown above is a list containing only keys of the dictionary d, in the form of a list.
#Answer: c Explanation: Execute in the shell to verify.
#Answer: c Explanation: More than one key can have the same value.
#Answer: c Explanation: del deletes the entire dictionary and any further attempt to access it will throw an error.
#Answer: a Explanation: The method popitem() removes a random key-value pair.
#Answer: c Explanation: The insert() function counts the number of occurrences of the item being inserted into the dictionary. There are only 2 keys present since the key ‘Apple’ is repeated. Thus, the length of the dictionary is 2.
#Answer: c Explanation: The above piece of code basically finds the sum of the values of keys.
#Answer: d Explanation: Dictionary in a dictionary can exist.
#Answer: a Explanation: In the second line of code, the dictionary becomes an empty dictionary. Thus, length=0.
#Answer: b Explanation: After the key-value pair of 1:’A’ is deleted, the key-value pair of 1:’D’ is added.
#Answer: c Explanation: The value of key 1 is 4 since 1 and 1.0 are the same. Then, the function count() gives the sum of all the values of the keys (2+4).
#Answer: d Explanation: Mutable members can be used as the values of the dictionary but they cannot be used as the keys of the dictionary.
#Answer: c Explanation: The statement a=collections.OrderedDict() generates a dictionary with the number as the key and the count of times the number appears as the value.
#Answer: d Explanation: The most_common() method returns the n number key-value pairs where the value is the most recurring.
#Answer: d Explanation: The most_common() method returns the n number key-value pairs where the value is the most recurring.
#Answer: a Explanation: a|b returns the pair of keys and the highest recurring value.
#Answer: b Explanation: a&b returns the pair of keys and the lowest recurring value.
#Answer: b Explanation: The values of a dictionary can be accessed using keys but the keys of a dictionary can't be accessed using values.
#Answer: c Explanation: Option c is a set, not a dictionary.
#Answer: a Explanation: In the above code, variables i and j iterate over the keys and values of the dictionary respectively.
#Answer: b Explanation: The get() method returns the value of the key if the key is present in the dictionary and the default value(second parameter) if the key isn't present in the dictionary.
#Answer: d Explanation: The get() method returns the default value(second parameter) if the key isn't present in the dictionary.
#Answer: b Explanation: setdefault() is similar to get() but will set dict[key]=default if key is not already in the dictionary.
#Answer: a Explanation: setdefault() will set dict[key]=default if key is not already in the dictionary.
#Answer: c Explanation: update() method adds dictionary b's key-value pairs to dictionary a. Execute in python shell to verify.
#Answer: b Explanation: Changes made in the copy of the dictionary isn't reflected in the original one.
#Answer: d Explanation: The clear() method clears all the key-value pairs in the dictionary.
#Answer: c Explanation: Keys of a dictionary may be any data type that is immutable.
#Answer: b Explanation: pop() method removes the key-value pair for the key mentioned in the pop() method.
#Answer: a Explanation: pop() method returns the value when the key is passed as an argument and otherwise returns the default value(second argument) if the key isn't present in the dictionary.
#Answer: a Explanation: The variable i iterates over the keys of the dictionary and hence the keys are printed.
#Answer: d Explanation: The method items() returns list of tuples with each tuple having a key-value pair.
#Answer: d Clarification: Dictionaries are created by specifying keys and values.
#Answer: b Clarification: Dictionaries appear in the form of keys and values.
#Answer: a Clarification: In can be used to check if the key is int dictionary.
#Answer: b Clarification: If d2 was initialized as d2 = d1 the answer would be true.
#Answer: c Clarification: Arithmetic > operator cannot be used with dictionaries.
#Answer: a Clarification: Execute in the shell to verify.
#Answer: c Clarification: Execute in the shell to verify.
#Answer: b Clarification: Execute in the shell to verify.
#Answer: a Clarification: The output of the code shown above is a list containing only keys of the dictionary d, in the form of a list.
#Answer: c Clarification: Execute in the shell to verify.
