Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 ## C. Dictionary 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

1 ## C. Dictionary 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 4 5 6 -

1 ## C. Dictionary 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 4 5 6 - You are given two lists: 1. list states holds names of 50 US states + DC 2. list gdps holds GDPS of them in order 7 8 - Write a program to: 1. change the string GDPS to integer type. For example: '$54,020 --> 54020 2. create a dictionary to hold all pairwise data using state: GDP as key:value 3. sort the states by GDP values in descending order, then print them out 4. find the total GDP in the US. # Here is the first part of outputs: # state GDP =============== ======== 3290170 1950359 1868224 1198913 938216 832704 732117 673872 671483 661520 646207 'Colorado', 'Connecticut', 'Illinois', 'Indiana', 'Iowa', 'Massachusetts', 'Michigan', 2 In [*]: 1 states ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'california', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Kansas', 'Kentucky', 'Louisiana' 'Maine', 'Maryland', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'Washington D.C.', 'West Virginia', 'Wisconsin', 'Wyoming"] California Texas New York Florida Illinois Pennsylvania Ohio Georgia New Jersey Washington North Carolina 9 10 gdps = ['$243,555', '$54,020', '$400,156', '$143,438', '$3,290,170', '$416,937', '$294,649' 11 12 13 14 15 16 17 '$79,282', '$1,198,913', '$673,072', '$89,661', '$92,300', '$938,216', '$415,344', '$220,929', '$193,139', '$234,311', '$253,315', '$74,684', '$443,729', '$625,113', '$559,479', '$407,395', '$123,781', '$359,034', '$57,919', '$150,507', '$187,394', '$93,891', '$671,483', '$108,241', '$1,868,224', '$646,207', '$64,978', '$732,117', '$285,559', '$264,113', '$832,704', '$64,170', '$266,079", '$60,810', '$411,689', '$1,950,359', '$212,855', '$36,089', '$586,250', '$661,520', '$151,390, '$85,799', '$363,586', $41,199] 18 19 # Len(gdps) # 51 20 # Len(states) # 51 21 #------ 22 # YOUR CODE HERE 23 24 # (1) change all gdps from string to Integer 25 26 27 28 29 30 # (2) use zip to generate a dictionary 31 32 33 34 35 36 # (3) sort them by GDP in descending order 37 38 39 40 41 42 43 # (4) total GDP: 44 45 46

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

Recommended Textbook for

Intermediate Algebra

Authors: Margaret Lial, John Hornsby, Terry McGinnis

13th Edition

0134895983, 978-0134895987

More Books

Students also viewed these Programming questions

Question

Was the treatment influenced by being novel or disruptive?

Answered: 1 week ago

Question

Solve each equation. 3Vx 12V/2x + 2 -

Answered: 1 week ago

Question

Add or subtract as indicated. 46.88 - 13.45

Answered: 1 week ago

Question

Explain the characteristics of the three types of needs.

Answered: 1 week ago

Question

Recognize some of the factors that contribute to obesity.

Answered: 1 week ago

Question

Identify the physical and social factors that influence hunger.

Answered: 1 week ago