71. What will be the output of the following Python code snippet?
a = {}
a[1] = 1
a['1'] = 2
a[1]=a[1]+1
count = 0
for i in a:
count += a[i]
print(count)
a = {}
a[1] = 1
a['1'] = 2
a[1]=a[1]+1
count = 0
for i in a:
count += a[i]
print(count)
72. What will be the output of the following Python code?
>>> import collections
>>> a=dict()
>>> a=collections.defaultdict(int)
>>> a[1]
>>> import collections
>>> a=dict()
>>> a=collections.defaultdict(int)
>>> a[1]
73. Suppose d = {"john":40, "peter":45}, what happens when we try to retrieve a value using the expression d["susan"]?
74. What will be the output of the following Python code snippet?
a={}
a['a']=1
a['b']=[2,3,4]
print(a)
a={}
a['a']=1
a['b']=[2,3,4]
print(a)
75. What will be the output of the following Python code?
>>> a={'B':5,'A':9,'C':7}
>>> sorted(a)
>>> a={'B':5,'A':9,'C':7}
>>> sorted(a)
76. What will be the output of the following Python code?
>>> import collections
>>> b=dict()
>>> b=collections.defaultdict(lambda: 7)
>>> b[4]
>>> import collections
>>> b=dict()
>>> b=collections.defaultdict(lambda: 7)
>>> b[4]
77. What will be the output of the following Python code?
>>> a={"a":1,"b":2,"c":3}
>>> b=dict(zip(a.values(),a.keys()))
>>> b
>>> a={"a":1,"b":2,"c":3}
>>> b=dict(zip(a.values(),a.keys()))
>>> b
78. Which of the following isn't true about dictionary keys?
79. What will be the output of the following Python code?
>>> a={i: 'A' + str(i) for i in range(5)}
>>> a
>>> a={i: 'A' + str(i) for i in range(5)}
>>> a
80. What will be the output of the following Python code?
>>> b={}
>>> all(b)
>>> b={}
>>> all(b)