MCQ Answer

<p>What will be the output of the following Python code snippet?</p> <pre><font color="#333333">a = {}<br></font><font color="#333333">a[1] = 1<br></font><font color="#333333">a['1'] = 2<br></font><font color="#333333">a[1]=a[1]+1<br></font><font color="#333333">count = 0<br></font><font color="#333333">for i in a:&nbsp;<br></font><font color="#333333">&nbsp; &nbsp; count += a[i]<br></font><font color="#333333">print(count)</font></pre>

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)


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

a = {}
a[1] = 1
a['1'] = 2
a[1]=a[1]+1
count = 0
for i in a: 
    count += a[i]
print(count)
Topic : Sequence data types in python

A. 1

B. 2

C. 4

D. Error, the keys can’t be a mixture of letters and numbers एरर,keys लेटर्स और नंबर्स का मिक्चर नहीं हो सकता




Correct Answer is :

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