Which data structure in Python would you use to store a collection of unique elements?
- Dictionary
- List
- Set
- Tuple
You would use a Set in Python to store a collection of unique elements. Sets do not allow duplicate values, and they are commonly used to work with unique items. Lists (option 1) and Tuples (option 2) allow duplicate elements, and Dictionaries (option 4) store key-value pairs.
Loading...
Related Quiz
- The ____ function in TensorFlow or PyTorch is used to compute the gradient of a computation with respect to its input variables.
- Which sorting algorithm is best suited for large datasets?
- Which Python built-in function will you use to sort a list of numbers in ascending order?
- The _______ method is used to remove and return an arbitrary element from a set.
- What keyword is used to define a function in Python?