Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Tuples as return types in functions
Tuples as records
6. Tuples representing real-world objects
List of tuples


Perfect! In Python, tuples are also frequently used as "records", i.e., sets of values which describe a real-world object, such as a person, an event, a machine, and so on.

For instance, here is a tuple which represents a lecture at a university:

# (title, lecturer, room)
economy_lecture = ('Intro to Economy', 'John Twain', 208)

Another example shows how we can represent a person:

# (name, age, gender)
person = ('Anne', 32, 'female')

In the following explanations, we'll be using tuples to represent cars. Each tuple will store the car's make, price (in USD), and mileage (in kilometers):

car_to_sell = ('Volvo', 18000, 137000)


Create a tuple for an employee. It should contain three elements: their name, position, and monthly salary. Name this tuple new_hire.

The employee is called "Mark Adams", he's an "SQL Analyst", and he earns $4,000 a month.

Stuck? Here's a hint!

Create the tuple in the following way:

new_hire = ('Mark Adams', 'SQL Analyst', 4000)