Report Bug

Qus

What will be the output of the following Python code snippet?

a={}
a['a']=1
a['b']=[2,3,4] 
print(a)
Qus

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

a={}
a['a']=1
a['b']=[2,3,4] 
print(a)


A. Exception is thrown
B. {‘b’: [2], ‘a’: 1}
C. {‘b’: [2], ‘a’: [3]}
D. {'a': 1, 'b': [2, 3, 4]}


Solution
D. {'a': 1, 'b': [2, 3, 4]}



Explanation
Mutable members can be used as the values of the dictionary but they cannot be used as the keys of the dictionary.
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz