Tuples
Learn about the tuple object in Python.
We'll cover the following...
Definition
A tuple consists of two or more values separated by commas and enclosed in parentheses, for example, ("John", 23)
.
Press + to interact
tup1 = (1, 2, 3) # Tuple of integersprint(tup1)tup2 = (7, "Great", 1.52, True) # Tuple of mixed data typesprint(tup2)
Tuples are useful for keeping a small number of values together as a single unit. For example, you might want to write a function that returns the x-y coordinates of an object, or the largest and smallest values in a ...