Report Bug

Qus

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

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

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


A. 1
B. 2
C. 4
D. Error, the keys can’t be a mixture of letters and numbers


Solution
C. 4



Explanation
The above piece of code basically finds the sum of the values of keys.
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad