Junior — Middle
What method in Python implements a data structure that allows storing a set of elements of different types in an immutable form?
sobes.tech AI
Answer from AI
In Python, a tuple is used to store a set of elements of different types in an immutable form. A tuple is an ordered, immutable collection that can contain elements of any types, including other tuples, lists, numbers, strings, etc.
Example of creating a tuple:
my_tuple = (1, "string", 3.14, True)
print(my_tuple)
Attempting to modify an element of a tuple will result in an error, as tuples are immutable.