For this program you may work with one partner (you may not work in groups larger than two).
If you work with a partner:
The best way to work with a partner is to work together in the lab on all parts of the program. If you need to share a file, here are two ways to do this:
fennel[~]$ cd cs21/labs/09 fennel[09]$ mail knerr < zipcodes.py fennel[09]$ scp zipcodes.py knerr@lab:cs21/labs/09/. knerr@lab's password: zipcodes.py 100% 88 0.1KB/s 00:00 fennel[09]$
In the first example the user emails the file to knerr. In the second example scp (secure copy) is used to copy the file from the user to knerr's cs21/labs/09 directory. This obviously requires knerr's password.
Run update21, if you haven't already, to create the cs21/labs/09 directory. Then cd into your cs21/labs/09 directory and create the python program for the lab in this directory (handin21 looks for your solutions here).
$ update21 $ cd cs21/labs/09
What US city has the zip code 12345? What is the zip code for Truth or Consequences, NM? Your assignment this week is to create a program (zipcodes.py) that allows the user to explore a zip code database.
We have a file, /usr/local/doc/zipcodes.txt, which contains zip code data for most of the United States. Each line of the file contains seven fields separated by commas:
19081,39.897562,-075.346584,Swarthmore,Delaware,PA,9907
Your program should prompt the user for either a zip code or at least part of a city name. Depending on what the user types, your program should do one of the following:
$ python zipcodes.py
Welcome to the zip codes database.
This program will look up data based on zip code or city name.
It will display the state boundaries with the locations of
major cities in blue, and the location of the city of interest
in red.
Enter zip code or city: 10901
10901 Suffern, NY Rockland County Pop: 21760
Cities in NY with populations greater than 150000
Schenectady Pop: 156661
Astoria Pop: 165859
Yonkers Pop: 176600
Flushing Pop: 214473
Jamaica Pop: 216876
Syracuse Pop: 231585
Staten Island Pop: 443728
Rochester Pop: 488602
Buffalo Pop: 598640
Bronx Pop: 1327690
New York Pop: 1529375
Brooklyn Pop: 2465326

Enter zip or city: london
Here are the cities that match your query
03053 Londonderry, NH Rockingham County Pop: 23148
05148 Londonderry, VT Windham County Pop: 792
25126 London, WV Kanawha County Pop: 305
40741 London, KY Laurel County Pop: 36324
40742 London, KY Laurel County Pop: 36324
40743 London, KY Laurel County Pop: 36324
40744 London, KY Laurel County Pop: 36324
40745 London, KY Laurel County Pop: 36324
43140 London, OH Madison County Pop: 22135
45647 Londonderry, OH Ross County Pop: 1889
61544 London Mills, IL Fulton County Pop: 706
72847 London, AR Pope County Pop: 2631
76854 London, TX Kimble County Pop: 322
Enter zip or city: 76854
76854 London, TX Kimble County Pop: 322
Cities in TX with populations greater than 150000
Brownsville Pop: 159481
Laredo Pop: 190759
Irving Pop: 192610
Garland Pop: 215555
Lubbock Pop: 219631
Plano Pop: 225287
Corpus Christi Pop: 278829
Arlington Pop: 338858
El Paso Pop: 634240
Fort Worth Pop: 678401
Austin Pop: 747080
Dallas Pop: 1261999
San Antonio Pop: 1308200
Houston Pop: 2571090

Enter zip or city: 145555
Sorry no zip code matching your query was found.
Enter zip or city: pickles
Sorry no cities matching your query were found.
Enter zip or city: vien
Here are the cities that match your query
04360 Vienna, ME Kennebec County Pop: 515
07880 Vienna, NJ Warren County Pop: 0
21869 Vienna, MD Dorchester County Pop: 1039
22180 Vienna, VA Fairfax County Pop: 59531
22181 Vienna, VA Fairfax County Pop: 59531
22182 Vienna, VA Fairfax County Pop: 59531
22183 Vienna, VA Fairfax County Pop: 59531
22184 Vienna, VA Fairfax County Pop: 59531
22185 Vienna, VA Fairfax County Pop: 59531
26105 Vienna, WV Wood County Pop: 11923
31092 Vienna, GA Dooly County Pop: 5680
44473 Vienna, OH Trumbull County Pop: 4215
57271 Vienna, SD Clark County Pop: 463
62995 Vienna, IL Johnson County Pop: 5953
65582 Vienna, MO Maries County Pop: 2241
Enter zip or city: 31092
31092 Vienna, GA Dooly County Pop: 5680
Cities in GA with populations greater than 150000
Macon Pop: 163507
Lawrenceville Pop: 165459
Columbus Pop: 169136
Decatur Pop: 176163
Augusta Pop: 198378
Savannah Pop: 218659
Marietta Pop: 302216
Atlanta Pop: 673017

Enter zip or city: <Enter> Goodbye.
You should practice good top-down design, incrementally implement and test your solution, and document your code with comments. We encourage you to finish the text part of this program before you add the graphics. This makes testing easier and faster. Once you have the text portion working, then add the graphics. While much of the design is up to you, your program should follow the guidelines given below.
from boundaries import * state = "VA" w = getStateGraphWin(state) if w != None: # plot all zip codes for this state here # use points based on the longitude and lattitude for each zip code w.getMouse() w.close()
The zip code data file we have provided you is by no means complete. Some zip codes were missing or did not have lat/long data and were removed. For some cities, we did not have population data, so we set the population arbitrarily to 0. If your favorite US city or hometown in the US is missing and you know all the info (zip code, city name, county name, state, lat, long, and population), let us know and we will be happy to add a few cities, but we are not trying to maintain a comprehensive list.
This is not required and should only be attempted after you have completed the lab. When reporting the largest cities in a state, list them in sorted order by population.
Once you are satisfied with your program, hand it in by typing handin21 in a terminal window.