7.6. Exercises

7-1. Dictionary Methods. What dictionary method would we use to combine two dictionaries together?

7-2. Dictionary Keys. We know that dictionary values can be arbitrary Python objects, but what about the keys? Try using different types of objects as the key other than numbers or strings. What worked for you and what didn't? As for the failures, why do you think they didn't succeed?

7-3. Dictionary and List Methods.

(a) Create a dictionary and display its keys alphabetically.

(b) Now display both the keys and values sorted in alphabetical order by the key.

(c) Same as part (b), but sorted in alphabetical order by the value. (Note: this generally has no practical purpose in dictionaries or hash tables in general because most access and ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.