Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python programming: Part One Reading a data file For this exercise, you will need to download the file States.txt from Canvas and save it into

python programming:

Part One Reading a data file

For this exercise, you will need to download the file States.txt from Canvas and save it into the same directory as your Python script. To do this, login to Canvas, select CIS 41A, select Files, select States.txt, select Download, and save into the same directory with your unit G take-home Python script.

The file has 50 lines of data, one for each state in the Unites States. Each line of data contains three pieces of data separated by a space: the two letter abbreviation of the state's name, the region that the state is in, and the 2016 population of the state.

You need to find and print the state with the highest population in the Midwest region.

Example output:

Highest population state in the Midwest is: IL 12802000 

Part Two A Dictionary of Lists

Download the file USPresidents.txt from from Canvas and save it into the same directory as your Python script. To do this, login to Canvas, select CIS 41A, select Files, select USPresidents.txt, select Download, and save into the same directory with your unit G take-home Python script.

The file has 44 lines of data, one for each president in the history of the Unites States. Each line of data contains two pieces of data separated by a space: the two letter abbreviation of the name of the state where the president was born, and the name of the president (for your convenience, the president's name has been converted to a single string George Washington has been converted to George_Washington).

Using the data from the file, you need to build a dictionary of states and the presidents born in those states. Each key will be a state abbreviation and each value will be a list of presidents.

After building the dictionary, determine the state with the most presidents and how many presidents were born there. Print their names.

Example output:

The state with the most presidents is VA with 8 presidents: George_Washington James_Madison James_Monroe John_Tyler And so on... 

Part Three Dictionary Keys and Sets

Build a second dictionary from the USPresidents.txt file described in the previous exercise. Each key will again be a state abbreviation, however, the value will be the count of presidents from that state.

Create a set of the ten most populous US states (CA, TX, FL, NY, IL, PA, OH, GA, NC, MI).

Then create a new set that represents a set of populous US states that have had presidents born in them (you should be able to do this with one line of code).

Print a count of this new set along with an alpha-sorted listing of these states and how many presidents have been born in them.

Example output:

8 of the 10 high population states have had presidents born in them: CA 1 GA 1 IL 1 NC 2 And so on...

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago

Question

2. Define identity.

Answered: 1 week ago

Question

1. Identify three communication approaches to identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago