Junior — Middle
What built-in data structures are available in Python?
sobes.tech AI
Answer from AI
Python provides the following built-in data structures:
- list — a mutable ordered collection of elements.
- tuple — an immutable ordered collection of elements.
- dict — a dictionary that stores key-value pairs.
- set — a collection of unique elements.
- frozenset — an immutable set.
Example usage:
my_list = [1, 2, 3]
my_tuple = (1, 2, 3)
my_dict = {'a': 1, 'b': 2}
my_set = {1, 2, 3}
my_frozenset = frozenset([1, 2, 3])
These structures cover most tasks related to data storage and processing.