PRACTICE • LEARN • GROW
Module 6: Core Data Structures - Final Quiz MCQs
Solve topic-wise placement questions and improve your skills.
Module 6: Core Data Structures - Final Quiz Progress
0 of 13 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
What is the time complexity of appending an element to the end of a Python list using
list.append()?
A.
O(1) amortized
B.
O(n)
C.
O(log n)
D.
O(n^2)
Explanation & Key
Correct Answer:
2
What is the difference in length between these two list operations?
a = [1, 2]
a.append([3, 4])
b = [1, 2]
b.extend([3, 4])
print(len(a), len(b))
A.
4 4
B.
3 4
C.
3 3
D.
2 4
Explanation & Key
Correct Answer:
3
What will be printed by modifying a nested list inside a shallow copy?
orig = [[1, 2], [3, 4]]
copy_list = orig.copy()
copy_list[0][0] = 99
print(orig[0][0])
A.
1
B.
99
C.
TypeError
D.
None
Explanation & Key
Correct Answer:
4
How do you create a tuple containing exactly ONE integer element with the value 42?
A.
t = (42)
B.
t = (42,)
C.
t = tuple[42]
D.
t = {42}
Explanation & Key
Correct Answer:
5
What will be printed by the following tuple unpacking with the rest operator?
first, *middle, last = [10, 20, 30, 40, 50]
print(middle)
A.
(20, 30, 40)
B.
[20, 30, 40]
C.
20, 30, 40
D.
[20, 30]
Explanation & Key
Correct Answer:
6
What will be the length of the set created from duplicate elements?
s = {1, 2, 2, 3, 3, 3}
print(len(s))
A.
6
B.
3
C.
1
D.
TypeError
Explanation & Key
Correct Answer:
7
What is the output of the following set algebra operations?
a = {1, 2, 3}
b = {3, 4, 5}
print(a & b, a - b)
A.
{3} {1, 2}
B.
{1, 2, 3, 4, 5} {4, 5}
C.
{3} {4, 5}
D.
{1, 2} {3}
Explanation & Key
Correct Answer:
8
What condition must an object meet to be used as a Dictionary key or Set element in Python?
A.
It must be an integer
B.
It must be hashable and immutable (implementing __hash__ and __eq__)
C.
It must be iterable
D.
It must have a string representation
Explanation & Key
Correct Answer:
9
What happens when executing d["country"] on a dictionary that does NOT contain that key?
A.
Returns None
B.
Raises a KeyError
C.
Inserts 'country': None into the dictionary
D.
Returns an empty string
Explanation & Key
Correct Answer:
10
Since Python 3.7, what guarantee is officially part of the Python language specification regarding dictionary keys?
A.
Keys are sorted in alphabetical order automatically
B.
Insertion order of keys is strictly preserved
C.
Dictionaries are thread-safe without locks
D.
Keys can be mutable lists
Explanation & Key
Correct Answer:
11
What will happen if you attempt to use a list as a dictionary key?
d = {}
d[[1, 2]] = "test"
A.
Stores the key successfully
B.
Raises TypeError: unhashable type: 'list'
C.
Converts the list to a string automatically
D.
Converts the list to a tuple
Explanation & Key
Correct Answer:
12
Which data structure from the
collections module should you choose when you need $O(1)$ constant time pops and appends at BOTH ends?
A.
collections.defaultdict
B.
collections.deque
C.
collections.Counter
D.
collections.OrderedDict
Explanation & Key
Correct Answer:
13
What is the output of the following dictionary update code?
info = {"name": "Asha", "role": "Dev"}
info["role"] = "Lead"
print(len(info), info["role"])
A.
2 Lead
B.
3 Lead
C.
2 Dev
D.
3 Dev
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong