Top 100 Python Data Structures MCQs with Answers

To prepare for Python Data Structures, you need a strong knowledge of core built-in types like Lists, Tuples, Sets, and Dictionaries. It is also essential to understand standard library modules such as collections and copy, along with concepts like time complexity and comprehensions.

In this article, we have combined all these important topics into a single set of 100 Python Data Structures MCQs. These questions cover everything from basic operations to advanced logic, helping you prepare for coding interviews and competitive exams in 2026-2027.

100 Python Data Structures MCQs

Below are 100 Python Data Structures MCQs. If you get most of them right, you are interview-ready. If not… well, it’s time to revise.

Q1. Which built-in data structure in Python is ordered and changeable, allowing duplicate members?

A. Tuple
B. Set
C. List
D. Dictionary

Show Answer

Answer: C
A List is ordered, mutable (changeable), and allows duplicate elements.

Q2. Which of the following data structures is immutable and ordered in Python?

A. List
B. Dictionary
C. Tuple
D. Set

Show Answer

Answer: C
Tuples are ordered collections that cannot be modified after creation (immutable).

Q3. Which data structure does not allow duplicate values in Python?

A. List
B. Tuple
C. Set
D. Dictionary (Values)

Show Answer

Answer: C
A Set is an unordered collection of unique elements, meaning it automatically removes duplicates.

Q4. What is the output of the following Python code: print(type({}))?

A.
B.
C.
D.

Show Answer

Answer: B
Empty curly braces {} create an empty dictionary, not a set.

Q5. Which method is used to add an element to the end of a list?

A. insert()
B. add()
C. append()
D. extend()

Show Answer

Answer: C
The append() method adds a single item to the end of the list.

Q6. How do you create an empty set in Python?

A. {}
B. set()
C. []
D. ()

Show Answer

Answer: B
You must use the set() constructor because {} is reserved for empty dictionaries.

Q7. Which of the following is true regarding Dictionary keys?

A. Keys must be mutable
B. Keys must be integers
C. Keys must be immutable
D. Keys can be duplicated

Show Answer

Answer: C
Dictionary keys must be immutable types (like strings, numbers, or tuples) so they can be hashed.

Q8. What will be the output of len([1, 2, 3, 4][1:3])?

A. 2
B. 3
C. 4
D. Error

Show Answer

Answer: A
Slicing [1:3] extracts elements at index 1 and 2, resulting in [2, 3], which has length 2.

Q9. Which method removes the last element from a list and returns it?

A. remove()
B. delete()
C. pop()
D. clear()

Show Answer

Answer: C
The pop() method removes and returns the item at the given index (default is last).

Q10. What is the time complexity of accessing an element in a dictionary by key?

A. O(n)
B. O(log n)
C. O(1)
D. O(n^2)

Show Answer

Answer: C
Dictionary lookups average O(1) time complexity due to the underlying hash table implementation.

Q11. Which of the following data types can be used as a key in a Python dictionary?

A. List
B. Dictionary
C. Tuple
D. Set

Show Answer

Answer: C
Tuples are immutable and hashable, making them valid dictionary keys.

Q12. What does the list method extend() do?

A. Adds a single element to the list
B. Removes an element from the list
C. Adds all elements of an iterable to the list
D. Increases the list size with None values

Show Answer

Answer: C
extend() iterates over its argument and adds each element to the list.

Q13. How do you access the value associated with the key ‘name’ in dictionary d?

A. d[‘name’]
B. d.get(‘name’)
C. d.value(‘name’)
D. Both A and B

Show Answer

Answer: D
Both bracket notation and the get() method are valid ways to access dictionary values.

Q14. What is the result of 3 * [1, 2] in Python?

A. [3, 6]
B. [1, 2, 1, 2, 1, 2]
C. Error
D. [[1, 2], [1, 2], [1, 2]]

Show Answer

Answer: B
The * operator repeats the elements of the list the specified number of times.

Q15. Which method is used to get a view object that displays a list of all keys in a dictionary?

A. values()
B. items()
C. keys()
D. list()

Show Answer

Answer: C
The keys() method returns a view object containing all the keys in the dictionary.

Q16. What is the output of set([1, 2, 2, 3, 3, 3])?

A. {1, 2, 2, 3, 3, 3}
B. {1, 2, 3}
C. [1, 2, 3]
D. Error

Show Answer

Answer: B
Sets remove duplicate values, leaving only unique elements.

Q17. Which operator is used to check if an element exists in a list or set?

A. exists
B. in
C. has
D. contains

Show Answer

Answer: B
The ‘in’ keyword checks for membership in Python iterables.

Q18. What happens if you try to access a list element with an index out of range?

A. Returns None
B. Returns False
C. Raises IndexError
D. Raises KeyError

Show Answer

Answer: C
Accessing an invalid index in a list triggers an IndexError.

Q19. How is a tuple with a single element created?

A. (1)
B. (1,)
C. [1]
D. {1}

Show Answer

Answer: B
A trailing comma is required for a single-element tuple to distinguish it from parentheses in expressions.

Q20. Which method removes a specific element by value from a list?

A. pop()
B. delete()
C. remove()
D. discard()

Show Answer

Answer: C
remove() deletes the first occurrence of the specified value from the list.

Q21. What type of data structure is best suited for implementing a LIFO (Last In First Out) mechanism?

A. Queue
B. Stack
C. Tree
D. Graph

Show Answer

Answer: B
A Stack follows the Last In First Out principle.

Q22. Which method adds an element to a set?

A. append()
B. add()
C. insert()
D. push()

Show Answer

Answer: B
The add() method is specific to sets for inserting single elements.

Q23. What is the output of the code: d = {‘a’: 1, ‘b’: 2}; print(d.get(‘c’, 3))?

A. None
B. KeyError
C. 3
D. 1

Show Answer

Answer: C
The get() method returns the default value (3) if the key is not found.

Q24. Which function sorts a list in place?

A. sorted()
B. sort()
C. order()
D. arrange()

Show Answer

Answer: B
The sort() method modifies the original list directly, whereas sorted() returns a new list.

Q25. Are strings mutable in Python?

A. Yes
B. No

Show Answer

Answer: B
Strings are immutable; operations on them create new string objects.

Q26. What is the result of set([1, 2]) & set([2, 3])?

A. {1, 2, 3}
B. {2}
C. {1, 3}
D. Error

Show Answer

Answer: B
The & operator performs intersection, returning elements common to both sets.

Q27. Which data structure would you use to store unique usernames?

A. List
B. Dictionary
C. Set
D. Tuple

Show Answer

Answer: C
Sets are ideal for storing unique items as they automatically enforce uniqueness.

Q28. What does the dictionary method popitem() do?

A. Removes the first inserted item
B. Removes the last inserted item
C. Removes a specific key
D. Clears the dictionary

Show Answer

Answer: B
popitem() removes and returns the last inserted key-value pair (LIFO order in Python 3.7+).

Q29. What is the index of the last element in a list with 5 elements?

A. 5
B. 4
C. -1
D. Both B and C

Show Answer

Answer: D
In Python, the last element is at index len-1 (4) or accessible via negative index -1.

Q30. Which of the following creates a shallow copy of a list L?

A. L.copy()
B. L[:]
C. list(L)
D. All of the above

Show Answer

Answer: D
All three methods create a shallow copy of the list.

Q31. Which method is used to remove an element from a set if it exists, without raising an error if it doesn’t?

A. remove()
B. delete()
C. discard()
D. pop()

Show Answer

Answer: C
discard() removes an element if present, otherwise does nothing; remove() raises an error.

Q32. What is the output of tuple([1, 2]) + tuple([3, 4])?

A. [1, 2, 3, 4]
B. (1, 2, 3, 4)
C. Error
D. {(1, 2), (3, 4)}

Show Answer

Answer: B
The + operator concatenates tuples to form a new tuple.

Q33. Which function returns the number of items in a container?

A. size()
B. length()
C. len()
D. count()

Show Answer

Answer: C
len() is the built-in function to determine the length or size of containers.

Q34. What is a Frozenset in Python?

A. A set that allows duplicates
B. An immutable version of a set
C. A set that is ordered
D. A frozen list

Show Answer

Answer: B
A frozenset is immutable and thus hashable, allowing it to be used as a dictionary key.

Q35. What is the output of [x**2 for x in range(3)]?

A. [0, 1, 2]
B. [1, 4, 9]
C. [0, 1, 4]
D. Error

Show Answer

Answer: C
This list comprehension squares numbers 0, 1, 2 resulting in [0, 1, 4].

Q36. How do you insert an element at a specific index in a list?

A. append()
B. insert()
C. push()
D. add()

Show Answer

Answer: B
insert(index, element) places the element at the specified position.

Q37. Which data structure allows fast membership testing compared to lists?

A. Tuple
B. Set
C. List
D. String

Show Answer

Answer: B
Sets use hash tables, making membership tests O(1) on average, faster than lists O(n).

Q38. What is the output of the code: a = [1, 2]; b = a; b.append(3); print(a)?

A. [1, 2]
B. [1, 2, 3]
C. Error
D. [3]

Show Answer

Answer: B
Lists are mutable and assigned by reference, so changes in ‘b’ reflect in ‘a’.

Q39. Which dictionary method returns a view of key-value pairs as tuples?

A. keys()
B. values()
C. items()
D. get()

Show Answer

Answer: C
The items() method returns a view object containing tuples of (key, value) pairs.

Q40. What happens if you try to change a value in a tuple?

A. The value changes
B. TypeError is raised
C. ValueError is raised
D. New tuple is created

Show Answer

Answer: B
Tuples are immutable, so modifying them raises a TypeError.

Q41. Which list method reverses the order of elements in place?

A. reverse()
B. reversed()
C. sort(reverse=True)
D. flip()

Show Answer

Answer: A
reverse() modifies the list in place; reversed() returns an iterator.

Q42. What is the output of len(set([1, 1, 1, 1]))?

A. 1
B. 4
C. 0
D. Error

Show Answer

Answer: A
The set removes all duplicates, leaving only {1}, so length is 1.

Q43. How do you remove all elements from a dictionary?

A. delete()
B. remove()
C. clear()
D. pop()

Show Answer

Answer: C
The clear() method empties the dictionary in place.

Q44. Which of the following is NOT a valid way to create a dictionary?

A. {}
B. dict()
C. {key: value}
D. [key: value]

Show Answer

Answer: D
Square brackets [] denote lists, not dictionaries.

Q45. What is the time complexity of inserting an element at the beginning of a list?

A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)

Show Answer

Answer: B
Inserting at the start requires shifting all existing elements, taking O(n) time.

Q46. What is list slicing?

A. Cutting the list into two
B. Extracting a portion of the list
C. Deleting elements
D. Sorting elements

Show Answer

Answer: B
Slicing allows you to extract a sub-list using the syntax [start:stop:step].

Q47. Which operator is used for union of two sets?

A. &
B. |
C. –
D. ^

Show Answer

Answer: B
The pipe operator | combines elements from both sets (union).

Q48. What does the count() method do for a list?

A. Counts total elements
B. Counts occurrences of a specific element
C. Counts unique elements
D. Counts None values

Show Answer

Answer: B
count(value) returns the number of times the value appears in the list.

Q49. Which of the following is a mutable data structure?

A. String
B. Tuple
C. Frozenset
D. List

Show Answer

Answer: D
Lists are mutable; elements can be added, removed, or changed.

Q50. How do you check if a key exists in a dictionary ‘my_dict’?

A. my_dict.has_key(k)
B. k in my_dict
C. my_dict.exists(k)
D. my_dict[k]

Show Answer

Answer: B
The ‘in’ operator checks for key existence in the dictionary.

Q51. What is the output of set(‘hello’)?

A. {‘hello’}
B. {‘h’, ‘e’, ‘l’, ‘l’, ‘o’}
C. {‘h’, ‘e’, ‘l’, ‘o’}
D. {‘h’, ‘e’, ‘o’}

Show Answer

Answer: C
Converting a string to a set creates a set of unique characters; ‘l’ is duplicated.

Q52. Which method updates a dictionary with elements from another dictionary?

A. append()
B. extend()
C. update()
D. merge()

Show Answer

Answer: C
update() adds key-value pairs from another dictionary, overwriting existing keys.

Q53. What is the difference between remove() and pop() for lists?

A. remove() deletes by index, pop() by value
B. remove() deletes by value, pop() by index
C. remove() returns the value, pop() does not
D. No difference

Show Answer

Answer: B
remove(value) finds and deletes the value; pop(index) removes and returns the item at index.

Q54. What data structure is internally used for dictionary implementation in Python?

A. Linked List
B. Binary Tree
C. Hash Table
D. Queue

Show Answer

Answer: C
Python dictionaries are implemented using hash tables for fast lookups.

Q55. Which comprehension syntax is used to create a dictionary?

A. [k:v for k in iter]
B. {k:v for k in iter}
C. (k:v for k in iter)
D.

Show Answer

Answer: B
Dictionary comprehensions use curly braces with a key-value pair expression.

Q56. What is the result of bool([])?

A. True
B. False
C. Error
D. None

Show Answer

Answer: B
Empty data structures (lists, dicts, tuples, sets) evaluate to False in a boolean context.

Q57. Which of these is an ordered data structure in Python 3.7+?

A. Set
B. Dictionary
C. Frozenset
D. Both A and B

Show Answer

Answer: B
As of Python 3.7, dictionaries maintain insertion order; sets do not.

Q58. How do you find the index of a specific value in a list?

A. find()
B. index()
C. search()
D. locate()

Show Answer

Answer: B
The index() method returns the first index where the value is found.

Q59. What is the difference between a list and a tuple?

A. Lists are mutable, tuples are immutable
B. Lists use (), tuples use []
C. Tuples are faster to create than lists
D. Both A and C

Show Answer

Answer: D
Lists are mutable and slower; tuples are immutable and generally faster.

Q60. What is the output of set([1, 2]) – set([2, 3])?

A. {1}
B. {3}
C. {2}
D. {1, 3}

Show Answer

Answer: A
The – operator performs set difference, returning elements in the first set but not the second.

Q61. Which function can be used to convert a list of tuples into a dictionary?

A. list()
B. tuple()
C. dict()
D. set()

Show Answer

Answer: C
The dict() constructor can convert a list of key-value tuples into a dictionary.

Q62. What does ‘for k, v in my_dict.items()’ do?

A. Iterates keys only
B. Iterates values only
C. Iterates key-value pairs
D. Error

Show Answer

Answer: C
It unpacks the tuples returned by items() into variables k (key) and v (value).

Q63. Which method copies a dictionary?

A. copy()
B. clone()
C. duplicate()
D. mirror()

Show Answer

Answer: A
The copy() method creates a shallow copy of the dictionary.

Q64. Can a list contain different data types (int, string, object)?

A. Yes
B. No

Show Answer

Answer: A
Python lists are heterogeneous and can store elements of different types.

Q65. What is the result of max([1, 5, 2, 9])?

A. 1
B. 9
C. 4
D. Error

Show Answer

Answer: B
The max() function returns the item with the highest value in the iterable.

Q66. Which operator finds the symmetric difference between two sets?

A. &
B. |
C. –
D. ^

Show Answer

Answer: D
The ^ operator returns elements in either set, but not in both.

Q67. How do you delete a specific key from a dictionary?

A. del dict[key]
B. dict.pop(key)
C. dict.remove(key)
D. Both A and B

Show Answer

Answer: D
Both the del keyword and the pop() method are valid ways to delete a key.

Q68. What is the output of [1, 2, 3][-2]?

A. 1
B. 2
C. 3
D. Error

Show Answer

Answer: B
Negative indexing accesses elements from the end; -1 is last, -2 is second to last.

Q69. Which module in Python supports mutable string operations?

A. string
B. str
C. io
D. None, strings are immutable

Show Answer

Answer: D
Strings are inherently immutable in Python core; no module changes this.

Q70. What is a nested list?

A. A list inside another list
B. A list with no elements
C. A list containing strings
D. A list of integers

Show Answer

Answer: A
A nested list is a list acting as an element within another list (matrix).

Q71. Which method sorts list elements in descending order?

A. sort(descending=True)
B. sort(reverse=True)
C. sort(backward=True)
D. sort(flip=True)

Show Answer

Answer: B
Passing reverse=True to the sort() method sorts the list in descending order.

Q72. What happens when you call pop() on an empty list?

A. Returns None
B. Returns False
C. Raises IndexError
D. Raises ValueError

Show Answer

Answer: C
pop() cannot remove an element from an empty list, so it raises an IndexError.

Q73. Which function is used to create a sequence of numbers, often for loops?

A. range()
B. seq()
C. num()
D. list()

Show Answer

Answer: A
range() generates an immutable sequence of numbers.

Q74. What is the output of ‘a’ in {‘a’: 1, ‘b’: 2}?

A. 1
B. True
C. False
D. Error

Show Answer

Answer: B
The ‘in’ operator checks for keys in a dictionary, returning True here.

Q75. What is the set method union() equivalent to?

A. &
B. |
C. –
D. ^

Show Answer

Answer: B
The pipe operator | is the shorthand for the union() method.

Q76. Which of these is true about list deletion?

A. del list clears the list
B. del list removes the variable
C. list.clear() clears the list
D. Both B and C

Show Answer

Answer: D
del list deletes the variable; clear() empties the content of the list object.

Q77. Can a tuple be used as a key in a dictionary if it contains a list?

A. Yes
B. No

Show Answer

Answer: B
A tuple containing a list is not hashable because lists are mutable, so it cannot be a key.

Q78. What is the starting index of a Python list?

A. 1
B. 0
C. -1
D. Depends on the system

Show Answer

Answer: B
Python uses zero-based indexing for lists.

Q79. Which of these functions returns a new sorted list from an iterable?

A. sort()
B. sorted()
C. order()
D. arrange()

Show Answer

Answer: B
sorted() returns a new list and works on any iterable; sort() is a list method.

Q80. What is the time complexity of appending an element to the end of a list?

A. O(n)
B. O(1)
C. O(log n)
D. O(n^2)

Show Answer

Answer: B
Appending to the end is amortized O(1) constant time.

Q81. How do you create a deep copy of a list?

A. list.copy()
B. list[:]
C. copy.deepcopy(list)
D. list(list)

Show Answer

Answer: C
The deepcopy function from the copy module creates recursive copies of nested objects.

Q82. What is a set comprehension?

A. Creating a set using loops inside {}
B. Comprehending the size of a set
C. Creating a list from a set
D. None of the above

Show Answer

Answer: A
Set comprehension uses curly braces with an expression to create sets concisely.

Q83. What does the list method clear() do?

A. Deletes the list variable
B. Removes all items from the list
C. Removes the first item
D. Removes the last item

Show Answer

Answer: B
clear() empties the list content, leaving an empty list []

Q84. Which method is used to find the position of a substring in a string?

A. index()
B. find()
C. Both A and B
D. search()

Show Answer

Answer: C
Both index() and find() return the position; find() returns -1 if not found, index() raises error.

Q85. What is the difference between append() and extend()?

A. append() adds iterable, extend() adds element
B. append() adds element, extend() adds iterable elements
C. append() is faster
D. extend() creates a new list

Show Answer

Answer: B
append() adds the object as a single item; extend() iterates and adds individual items.

Q86. What is the output of bool({})?

A. True
B. False
C. Error
D. None

Show Answer

Answer: B
An empty dictionary evaluates to False in a boolean context.

Q87. Which data structure is unordered, changeable, and indexed?

A. List
B. Tuple
C. Dictionary
D. Set

Show Answer

Answer: C
Dictionaries are changeable and indexed by keys; they are ordered as of Python 3.7.

Q88. Can you perform arithmetic operations like + on sets?

A. Yes
B. No

Show Answer

Answer: B
Sets support |, &, -, ^ but not the + operator for concatenation.

Q89. What happens if you define a dictionary with duplicate keys?

A. Error is raised
B. First value is used
C. Last value overwrites previous ones
D. Keys are renamed

Show Answer

Answer: C
If duplicate keys are provided, the last assigned value overwrites the previous ones.

Q90. What is the return type of the keys() method?

A. List
B. Tuple
C. Set
D. dict_keys object

Show Answer

Answer: D
It returns a view object (dict_keys) which reflects changes in the dictionary.

Q91. How do you unpack elements from a list into variables?

A. a, b = [1, 2]
B. a, b = (1, 2)
C. Both A and B
D. None of the above

Show Answer

Answer: C
Unpacking works with any iterable that has a matching number of elements.

Q92. Which of the following is a hashable data type?

A. List
B. Dictionary
C. Tuple
D. Set

Show Answer

Answer: C
Only immutable types like tuples (containing immutable elements) are hashable.

Q93. What is the output of ‘Hello'[-1]?

A. H
B. o
C. e
D. Error

Show Answer

Answer: B
Strings support negative indexing; -1 returns the last character.

Q94. Which method is specific to sets and adds multiple elements?

A. add()
B. update()
C. extend()
D. append()

Show Answer

Answer: B
update() adds multiple elements from an iterable to a set.

Q95. What is the default value returned by pop() if the list is not empty?

A. First element
B. Last element
C. Middle element
D. Random element

Show Answer

Answer: B
pop() defaults to removing and returning the item at index -1 (last).

Q96. Which module provides the deque (double-ended queue) data structure?

A. array
B. queue
C. collections
D. datastructures

Show Answer

Answer: C
The collections module provides specialized container datatypes like deque.

Q97. Are list comprehensions generally faster than for loops?

A. Yes
B. No

Show Answer

Answer: A
List comprehensions are optimized in CPython and are usually faster than explicit for loops.

Q98. What does the ‘is’ operator check for lists?

A. If values are equal
B. If they are the same object in memory
C. If lengths are equal
D. If types are equal

Show Answer

Answer: B
The ‘is’ operator checks for object identity, not value equality.

Q99. What is the output of list(range(5))?

A. [1, 2, 3, 4, 5]
B. [0, 1, 2, 3, 4]
C. [0, 1, 2, 3, 4, 5]
D. Error

Show Answer

Answer: B
range(5) generates numbers from 0 up to (but not including) 5.

Q100. Which exception is raised when accessing a non-existent key in a dictionary?

A. IndexError
B. ValueError
C. KeyError
D. TypeError

Show Answer

Answer: C
Accessing a missing key using bracket notation raises a KeyError.

Conclusion

Ahh, finally it’s over. This set of 100 Python Data Structures MCQs is crazy long, isn’t it? Well, if you get stuck on any question or answer, simply paste it into AI chatbots like ChatGPT or Gemini and ask for a detailed explanation. Once you understand the logic behind an answer, you will never ever forget it.

If you’re new to Data Structures in Python, it’s important to first build a strong foundation. For that, you can check out this beginner-friendly guide: Data Structures in Python (covers Lists, Tuples, Sets, Dictionaries basics, etc), and once you’re comfortable with the basics, come back to this question bank and test your knowledge again.

For a deeper understanding, explore runtime complexity concepts here. Also, learn Python Lists, one of the most commonly used data structures. Dictionaries (key–value storage) click here. These resources will help you build a strong foundation.

Also, make sure to bookmark this page for later revision. Just press Ctrl + D on Windows or Cmd + D on Mac so you can easily revisit these Python Data Structures MCQs anytime you need.

Aditya Gupta
Aditya Gupta
Articles: 17