Python Data Structures

Assess your knowledge of lists,tuples,sets,and dictionaries.

1. Which data structure is immutable in Python?
2. Which of the following are mutable data structures in Python?
3. A Python list can contain elements of different data types.
4. What is the method used to add an element to the end of a list?
5. Which data structure uses key-value pairs for storage?
6. Which operations can be performed on a set?
7. Dictionaries in Python 3.6 and earlier preserve the insertion order of keys.
8. What is the output of [1, 2, 3] + [4, 5]?
9. Name the data structure that cannot have duplicate elements.
10. Which data structures allow accessing elements by index?
11. Tuples can be modified after creation.
12. Which method removes and returns an arbitrary element from a set?
13. What is the output of len({'a': 1, 'b': 2})?
14. Which are valid dictionary key types?
15. The 'in' operator checks for the presence of a value in a dictionary by default.
16. What does list.extend([1, 2]) do compared to list.append([1, 2])?
17. What data structure is created with curly braces containing comma-separated values (no key-value pairs)?
18. Which methods are available for both lists and tuples?
19. Sets are ordered data structures in Python 3.7+.
20. Which data structure provides O(1) average time complexity for membership checks ('in' operator)?
Answered 0 of 0 — 0 correct