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.
Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad