Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

PYTHON 1. Create a class named State that will store information about a US state and provide methods to get, and set the data, and

PYTHON 1. Create a class named State that will store information about a US state and provide methods to get, and set the data, and compare the states. a. Data attributes: State Name, Capitol, Region, US House Seats, Population, COVID Deaths, Full Vaccination Rates, Median Household Income, and Violent Crime Rate. b. Initializer (__init__) c. Getter and setter methods for each field d. __gt__ method so that two State objects can be compared based on state names e. __str__ method so that a state object can be printed like a string 2. Create a program that will: a. Prompt user to enter the name of the CSV file, e.g., States.csv, as input to the system. b. Parse States.csv and create a list of State objects containing the data in the file. (Note: do not change States.csv file at all.) c. Repetitively print to the user a menu of the following options: 1) Print a State Report 2) Sort by State Name 3) Sort by Region 4) Sort by COVID Death Rate 5) Sort by Median Household Income 6) Sort by Violent Crime Rate 7) Sort by Full Vaccination Rate 8) Find and print state for a given State Name 9) Print Spearmans r Correlation Matrix 10) Exit Note that, in the menu, COVID Death Rate is the number of COVID deaths per 100,000 population. That is, Death Rate of a state is equal to its deaths divided by its population and then times 100,000. Violent Crime Rate from our dataset already is per 100,000 population. Full Vaccination Rate is the percentage of the population that have received full vaccination. This percentage is already given in our dataset. All sorting in the menu should sort the list of State objects into ascending order. Whenever a sorting is to be done, the program should first sort based on the selected criterion, and then sort State objects based on Name to break ties. The Spearmans r correlation between two fields is defined next section. Option 9 should print according to the following format: Median Household Income Violent Crime Rate Full Vaccination Rate COVID Death Rate X X X (Xs are the actual values your program computed, printed 4 digits after decimal point.) d. Program should have functions or methods to implement these options. Do check for validity of user inputs. e. The State report in option 1 should include all states and be in this form: Name Region MHI VCR Death Rate FVR ------------------------------------------------------------------------ Alabama South 50536 453.6 415.821 0.522 (MHI is shorthand for Median Household Income, VCR for Violent Crime Rate, and FVR for Full Vaccination Rate. Note: whenever printed, Death Rate should be printed 3 digits after the decimal point, VCR 1 decimal digit, and FVR 3 decimal digits.) e. The State report in option 8 should be in this form: Name: Alabama Region: South MHI: 50536 VCR: 453.6 Death Rate: 415.821 FV Rate: 0.522 (Again: Death Rate should be printed 3 digits after the decimal point, VCR 1 decimal digit, and FVR 3 decimal digits.) Spearmans r Correlation One way to tell the correlation between two rankings, whether they are positively or negatively related, of the same set of n elements is Spearmans r. Let R1 and R2 be two ascending rankings of the same set of n elements. Then the Spearmans r between R1 and R2 is CIS4930 - Project 2 Python Basics 3 In the formula, di is the rank difference of element i in the two rankings R1 and R2. Take one example. Let A, B, C, D be four states. Say we are to compute the Spearmans r between Death Rate and MHI for these four states. First, we would sort to get a ranking of them according to Death Rate, say, A

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students explore these related Databases questions

Question

7. What traps should she avoid?

Answered: 3 weeks ago

Question

6. What data will she need?

Answered: 3 weeks ago