Report Bug
Qus :

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)
print(a)

Qus

निम्नलिखित Ptyhon कोड स्निपेट का आउटपुट क्या होगा?

 a = {}
a[1] = 1
a['1'] = 2
a[1.0]=4
count = 0
for i in a:
    count += a[i]
print(count)
print(a)


A. An exception is thrown
B. 3
C. 6
D. 2


Solution
C. 6



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).



Report Bug