Question: Python help Create a function that reads data from a file and returns it in a data structure of your choice (e.g. a list or

Python help

Create a function that reads data from a file and returns it in a data structure of your choice (e.g. a list or dictionary).

Prompt the user to select a region to gather data fromYou can then read the contents of the file into your data structure. If you use a dictionary, you likely want the state name as the key, and a list of data about the state as the value. If you use a list, you likely want the state name as the first item in the list followed by the remaining data. You will only need states from the selected region in your data structure.

Append the following information to each state value (note that per capita means per person so you must divide by the population):

GDP per capita

Per capita personal income

That is, you have two new pieces of information in addition to those values read from the file.

Your code should check for invalid region names and continue to prompt until the user provides a valid region name.

Here is a link to the data file: http://www.cse.msu.edu/~cse231/Online/Projects/Project08/State_Data.csv

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!