Tuple Functions in Python
In Python, tuples are immutable sequences used to store multiple items in a single variable.
They are similar to lists but cannot be changed after creation. Below are all the commonly
used tuple functions and operations.
Built-in Tuple Functions and Methods:
len(tuple)
Returns the number of items in the tuple.
max(tuple)
Returns the largest item in the tuple (elements must be comparable).
min(tuple)
Returns the smallest item in the tuple (elements must be comparable).
sum(tuple)
Returns the sum of all numeric items in the tuple.
tuple(sequence)
Converts a sequence (like list or string) into a tuple.
count(value)
Returns the number of times a specified value appears in the tuple.
index(value)
Returns the first index of the specified value. Raises ValueError if not found.