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

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 Solution

3.34 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

split csv module split csv module Largest State Population ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction to Computing and Programming in Pytho Questions!