Lists, Tuples, and Sets
Lists (list)
Lists are ordered and mutable collections that can contain elements of different types.
fruits = ["apple", "banana", "cherry"]
fruits.append("orange")
They support indexing, slicing, methods like .append(), .remove(), and can contain other lists (nested lists).
Tuples (tuple)
Tuples are ordered and immutable collections.
coordinates = (10.5, 20.3)
They are ideal for representing data that should not change, such as positions, configurations, etc.
Sets (set)
Sets are unordered, mutable collections without duplicate elements.
numbers = {1, 2, 3, 3, 4} # The number 3 is stored only once
They support standard set operations: union, intersection, difference, etc.
a = {1, 2, 3}
b = {3, 4, 5}
print(a & b) # {3}
print(a | b) # {1, 2, 3, 4, 5}