Python Built-in Types MCQs

16 MCQs  — Data Types MCQs  (Page 2 of 2)

Does a Python dict preserve the order in which keys were inserted?
Only when OrderedDict is imported
Only for integer keys
No, order is random
Yes, guaranteed by the language since Python 3.7
Can a frozenset be an element of a set or a dictionary key?
Yes, because it is immutable and hashable
Only when it is empty
No, sets cannot be nested in any form
Only in Python 2
Which statement about a = 256; b = 256; a is b in CPython is most accurate?
It is usually True because of small-integer caching, but that is an implementation detail; use == to compare values
It is always False
It raises a TypeError
The language guarantees True for every integer