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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access