Tuples
A tuple is a collection of ordered objects. Tuple is an immutable object. Tuple are faster as compare to list.
In Python, a tuple is created by placing all the elements inside parentheses (), separated by commas (,).
Example:numbers = ('one', 'two', 'three')
print(numbers)
Function | Description |
---|---|
tuple(seq) | converts a list into a tuple |
min(tuple) | returns item from the tuple with a minimum value |
max(tuple) | returns item from the tuple with maximum value |
len(tuple) | gives the total length of the tuple |
cmp(tuple1, tuple2) | compares elements of both tuples |