Summary
In this lecture I explain why Python dictionaries are a more readable and efficient way to store related data than using tuples inside lists. I start by showing how to create an empty dictionary and then populate it with hurricane names as keys and their categories as values. I demonstrate that dictionary lookups run in O(1) time, keys must be unique (duplicates are overwritten silently), and values can be accessed, updated, or added with simple square‑bracket syntax. To avoid KeyError I use the .get method with a default value, and I illustrate copying a dictionary with .copy to prevent accidental changes to the original. Membership testing with the "in" operator and removal of entries with del are covered, followed by a brief note on hashing and the fact that dictionary ordering is not guaranteed in older Python versions.
Next, I contrast del with pop, showing that pop removes a key and returns its value. I then introduce the concept of parallel dictionaries: separate dicts that share the same storm‑name keys but store different attributes such as category, wind speed, and damage. While this works, I point out that it quickly becomes unwieldy. To improve readability I show how to nest dictionaries, creating a single top‑level dict where each storm name maps to another dict containing all its attributes. I demonstrate accessing nested data with successive brackets, e.g., storms["Milton"]["category"], and explain that values can be any type, including lists.
Finally, I assign a hands‑on exercise: build nested records for the storms Milton and Helene by pulling the appropriate values from the flat dictionaries storm_categories, storm_wind_miles_per_hour, and storm_damage_billions. The expected outcome is two nested dictionaries (milton_record and helene_record) that consolidate each storm’s category, wind speed, and damage, ready for further analysis or reporting. This approach streamlines data handling and sets the stage for more advanced processing in later sessions.