Kickstart 2020 with new opportunities! - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Built-in Functions Common to Most Data Structures
3. min() and max() – dictionaries
Summary

Instruction

Good job! The min() and max() functions also work with dictionaries but only examine keys by default. For instance, if we changed our list with requests processed on a given day into a dictionary, we could write the following code:

requests_processed = {1:12, 2:18, 3:15, 4:23, 5:24, 6:8, 7:0, 8:18, 9:14, 10:13}
max(requests_processed)

The code above will return 10 because that's the largest key in the dictionary. If you want to find the largest value, use the following code instead:

max(requests_processed.values())

The code above will return 24.

Exercise

A company decided to change its product names as part of a rebranding strategy.

The template code contains a dictionary that maps old names to new names. Create a function named very_first_name(dictionary) that, for input similar to the one from the template, returns the very first name (alphabetically) among all the old and new names treated as a single group of names.

Stuck? Here's a hint!

First, find the min() value among the keys and the min() value among the values. Then, print the min() of those two.