In the media folder available at MediaComputation.org, there is another piece of census data that includes city
Question:
In the media folder available at MediaComputation.org, there is another piece of census data that includes city information, state-city-populations.csv. The first few lines of this file look like this:
SUMLEV,STATE,COUNTY,PLACE,COUSUB,CONCIT,FUNCSTAT,NAME,STNAME,
CENSUS2010POP,ESTIMATESBASE2010,POPESTIMATE2010,POPESTIMATE2011,
POPESTIMATE2012,POPESTIMATE2013
040,01,000,00000,00000,00000,A,Alabama,Alabama,4779736,4779758,4785570, 4801627,4817528,4833722 162,01,000,00124,00000,00000,A,Abbeville
city,Alabama,2688,2688,2683,2690,2658,2651
162,01,000,00460,00000,00000,A,Adamsville
city,Alabama,4522,4522,4519,4496,4474,4448 1
Write the below functions in two ways: One with split and another with the csv module.
• Write the findCityPopulation function that returns the population in 2013 (last field) of an input city.
• Write a function findLargestCityInState and findSmallestCity InState to find the city with the largest and the smallest population (respectively) within a given state.
• Use both your state and city functions to answer some questions. Find the state with the largest population, and the state with the smallest population. Is the smallest city in the largest state larger or smaller than the smallest city in the smallest state? Is the largest city in the largest state larger or smaller than the largest city in the smallest state?
Step by Step Answer:
Introduction To Computing And Programming In Python A Multimedia Approach
ISBN: 9780134025544
4th Edition
Authors: Mark J. Guzdial, Barbara Ericson