61. What will be the output of the following Python code?
>>> a={i: i*i for i in range(6)}
>>> a
>>> a={i: i*i for i in range(6)}
>>> a
62. What will be the output of the following Python code snippet?
a = {}
a[1] = 1
a['1'] = 2
a[1.0]=4
count = 0
for i in a:
count += a[i]
print(count)
a = {}
a[1] = 1
a['1'] = 2
a[1.0]=4
count = 0
for i in a:
count += a[i]
print(count)
63. Which of the following is not a declaration of the dictionary?
64. What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
"john" in d
d = {"john":40, "peter":45}
"john" in d
65. What will be the output of the following Python code snippet?
total={}
def insert(items):
if items in total:
total[items] += 1
else:
total[items] = 1
insert('Apple')
insert('Ball')
insert('Apple')
print (len(total))
total={}
def insert(items):
if items in total:
total[items] += 1
else:
total[items] = 1
insert('Apple')
insert('Ball')
insert('Apple')
print (len(total))
66. If a is a dictionary with some key-value pairs, what does a.popitem() do?
67. What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
d["john"]
d = {"john":40, "peter":45}
d["john"]
68. What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
print(a.get(5,4))
a={1:"A",2:"B",3:"C"}
print(a.get(5,4))
69. What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
print(a.setdefault(3))
a={1:"A",2:"B",3:"C"}
print(a.setdefault(3))