Tuples · Python example
Unpack a coordinate tuple and calculate its distance from the origin.
Tuples group related values that should not change. Unpacking assigns each item to its own variable in one statement.
point = (4, 7)
x, y = point
distance = (x ** 2 + y ** 2) ** 0.5
print(f"x={x}, y={y}")
print(f"Distance from origin: {distance:.2f}")