Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Python code snippet? test = {1:'A', 2:'B', 3:'C'} del test[1] test[1] = 'D' del test[2] print(len(test))
Q2
What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 == d2
Q3
What will be the output of the following Python code? >>> a={} >>> a.fromkeys([1,2,3],"check")
Q4
What will be the output of the following Python code snippet? d = {"john":40, "peter":45} print(list(d.keys()))
Q5
Which of these about a dictionary is false?
Q6
What will be the output of the following Python code? count={} count[(1,2,4)] = 5 count[(4,2,1)] = 7 count[(1,2)] = 6 count[(4,2,1)] = 2 tot = 0 for i in count: tot=tot+count[i] print(len(count)+tot)
Q7
What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} for i,j in a.items(): print(i,j,end=" ")
Q8
What will be the output of the following Python code snippet? test = {1:'A', 2:'B', 3:'C'} test = {} print(len(test))
Q9
What will be the output of the following Python code? >>> import collections >>> a=dict() >>> a=collections.defaultdict(str) >>> a['A']
Q10
What is the output of the following code: my_dict = {'a': 1, 'b': 2} my_dict.popitem() print(my_dict)
Q11
What will be the output of the following Python code snippet? >>>import collections >>> b=collections.Counter([2,2,3,4,4,4]) >>> b.most_common(1)
Q12
What will be the output of the following Python code? >>> a=dict() >>> a[1]
Q13
The following Python code is invalid. class demo(dict): def __test__(self,key): return [] a = demo() a['test'] = 7 print(a)
Q14
What will be the output of the following code: keys = ['a', 'b', 'c'] values = 0 my_dict = dict.fromkeys(keys, values) print(my_dict)
Q15
What will be the output of the following Python code? >>> a={1:"A",2:"B",3:"C"} >>> a.items()
Q16
What will be the output of the following Python code snippet? d1 = {"john":40, "peter":45} d2 = {"john":466, "peter":45} d1 > d2
Q17
What will be the output of the following Python code? a={1:5,2:3,3:4} print(a.pop(4,9))
Q18
What will be the output of the following Python code? a={} a[2]=1 a[1]=[2,3,4] print(a[1][1])
Q19
What will be the output of the following Python code? >>> import collections >>> a=collections.OrderedDict((str(x),x) for x in range(3)) >>> a
Q20
What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} a.setdefault(4,"D") print(a)
Q21
Which of the statements about dictionary values if false?
Q22
Suppose d = {"john":40, "peter":45}. To obtain the number of entries in dictionary which command do we use?
Q23
What will be the output of the following Python code? a={1:"A",2:"B",3:"C"} for i in a: print(i,end=" ")
Q24
What will be the output of the following Python code snippet? >>> import collections >>> a=collections.Counter([3,3,4,5]) >>> b=collections.Counter([3,4,4,5,5,5]) >>> a&b
Q25
Which of the following statements create a dictionary?