Question: It's python. Please don't forget to print alpha-sorted states. Not random. Thank you // USPresdients.txt KY Abraham_Lincoln SC Andrew_Jackson NC Andrew_Johnson HI Barack_Obama OH Benjamin_Harrison
It's python. Please don't forget to print alpha-sorted states. Not random. Thank you
//
USPresdients.txt
KY Abraham_Lincoln SC Andrew_Jackson NC Andrew_Johnson HI Barack_Obama OH Benjamin_Harrison AR Bill_Clinton VT Calvin_Coolidge VT Chester_A_Arthur NY Donald_Trump TX Dwight_D_Eisenhower NY Franklin_D_Roosevelt NH Franklin_Pierce MA George_H_W_Bush CT George_W_Bush VA George_Washington NE Gerald_R_Ford NJ Grover_Cleveland MO Harry_S_Truman IA Herbert_Hoover OH James_A_Garfield PA James_Buchanan NC James_K_Polk VA James_Madison VA James_Monroe GA Jimmy_Carter MA John_Adams MA John_F_Kennedy MA John_Quincy_Adams VA John_Tyler TX Lyndon_B_Johnson NY Martin_Van_Buren NY Millard_Fillmore CA Richard_M_Nixon IL Ronald_Reagan OH Rutherford_B_Hayes NY Theodore_Roosevelt VA Thomas_Jefferson OH Ulysses_S_Grant OH Warren_G_Harding VA William_Henry_Harrison OH William_Howard_Taft OH William_McKinley VA Woodrow_Wilson VA Zachary_Taylor
//
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
Get step-by-step solutions from verified subject matter experts
