Chapters
Python114 chapters

Exercises

Tuples

3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.

Exercise 1

Make a tuple holding only the number 5, and print its type.

Python
one = (5)
print(type(one))
Exercise 2

Return both the smallest and largest number from the function, and unpack them.

Python
def min_max(numbers):
    # return both
    pass

low, high = min_max([3, 1, 4])
print(low, high)
Exercise 3

Use a tuple as a dictionary key and look one up.

Python
locations = {}
# map (0, 0) to "origin", then print the lookup