Quiz
Dictionaries
Your Task:
Given access to
- one dictionary named zip2state that maps each
zipcode to the abbreviation of the state in which it lies
(such as zip2state['63103'] = 'MO'),
-
and a second dictionary named zip2pop that maps each zipcode
to the population of that area
(e.g., zip2pop['63103'] = 20700).
you are to write a Python script that produces a new dictionary named
state2pop that maps each state abbreviation to the total
population of that state
(e.g., state2pop['MO'] = 5989128).
Note: Although this should not impact your solution, both of these
dictionaries represent zipcodes as strings, so as to consistenly use 5-digit
codes (without dropping leading zeros)
Files:
-
solution.py
A template for your solution. This code should be modified and
submitted electronically.
-
data.py
The source for the zip2state and zip2pop
dictionaries that are to be imported. You should not modify
or submit this file.
Michael Goldwasser
Last modified: Monday, 26 November 2018