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.
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad