Ques 1 Collection
Which collection type in Python is an ordered dictionary of key-value pairs?
a) List
b) Tuple
c) Set
d) OrderedDict
Ques 2 Collection
What is the output of the following code snippet?
from collections import deque my_deque = deque([1, 2, 3]) my_deque.appendleft(0) print(my_deque)
Ques 3 Collection
Which collection type in Python is an unordered collection of unique elements with constant-time average for basic operations?
a) List
b) Tuple
c) Set
d) OrderedDict
Ques 4 Collection
What is the output of the following Python Code?
from collections import defaultdict my_dict = defaultdict(int) my_dict['a'] += 1 my_dict['b'] += 2 print(my_dict['c'])
Ques 5 Collection
What is the output of the following Python Code?
from collections import ChainMap dict1 = {'a': 1, 'b': 2} dict2 = {'b': 3, 'c': 4} combined_dict = ChainMap(dict1, dict2) print(combined_dict['b'])