Vidyalelo
Python · Q31

MCQs for Python Dictionaries: Exam

Programming · Python · question 31

Q31

What will be the output of the following Python code? >>> import collections >>> a=collections.OrderedDict((str(x),x) for x in range(3)) >>> a

A.
{'2':2, '0':0, '1':1}
B.
OrderedDict([('0', 0), ('1', 1), ('2', 2)])
Answer
C.
An exception is thrown
D.
' '

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board