1 ## C. Dictionary 2 3 4 5 6 7 8 9 10 11 12 13...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Intermediate Algebra
ISBN: 9780134895987
13th Edition
Authors: Margaret Lial, John Hornsby, Terry McGinnis
Posted Date:
Students also viewed these programming questions
-
ANS: 2. In the current year, a small Holiday Inn franchise had sales of $1,800,000, fixed costs of $550,000, and total variable costs of $750,000. Next year, sales are forecast to increase by 25% but...
-
(20 points)Write a program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, convert the sum to the nearest integer, and print the result....
-
In the Federal Reserve Bank of Atlanta, Working Paper Series (October 2008), researchers presented a novel approach to identifying firms that discriminate against women. The researchers used the...
-
PepsiCo, Inc.s financial statements are presented in Appendix B. Financial statements of The Coca-Cola Company are presented in Appendix C. The complete annual reports of PepsiCo and Coca-Cola,...
-
Using the examples as a guide, write a structure for a. Hexanal b. O-chlorobenzaldehyde c. 4-heptanone d. Isopropyl methyl ketone e. Cyclobutanecarbaldehyde f. 3-octyn-2-one
-
Kiersted Financial Services was formed on November 1, 2014. During the month of November, the following events and transactions occurred: Nov. 1 Haakon Kiersted, the owner, invested $35,000 cash in...
-
Graph 17 , vertex \(a\) Find a Hamilton cycle of low weight for the given graph in Figure 12.362, beginning at the given vertex, and using the nearest neighbor method. What is the weight of the cycle?
-
Beth Corbins regular hourly wage rate is $16, and she receives an hourly rate of $24 for work in excess of 40 hours. During a January pay period, Beth works 45 hours. Beths federal income tax...
-
Bed & Bath, a retailing company, has two departments Hardware and Linens. The company s most recent monthly contribution format income statement follows: Total Department Hardware Linens Sales $ 4 ,...
-
The Apex Television Company has to decide on the number of 65 and 55 sets to be produced at one of its factories. Market research indicates that at most 280 of the 65 sets and 70 of the 55 sets can...
-
Explain why Lean approach is so important in creating a strong operation to facilitate meeting/beating the competition. Do some outside research and locate another company,other than the ones covered...
-
Find f. f(x) = cos(x), f(0) = 2, f'(0) = 6, f"(0) = 9 -sin(x) + 2x+3x+6 f(x)=sin(x)+2
-
25% yolume fraction of SiC particles (density 3.2 g cm ) are incorporated into an Al alloy MMC of density 2.825 g.cm .Compute the relative mass of the SiC using the RoM?
-
g(x) = =2x-3x with domain (-co, co) find all local maximum values and local minimum values
-
Plummet Corporation reported the book value of its net assets at $400,000 when Zenith Corporation acquired 100 percent ownership. The fair value of Plummet's net assets was determined to be $510,000...
-
s: 1. Was the IPO under priced? Describe how and why this happened. 2. What would have been a better issue price? 3. How much did the company gain/lose on the mis-pricing?
-
Exercise 10-67 Cash Dividends on Common and Preferred Stock Lemon Inc. has the following information regarding its preferred and common stock: Preferred stock, $30 par, 12% cumulative; 300,000 shares...
-
TRUE-FALSE QUESTIONS 1. In terms of preliminary analytical procedures, assume that the company has introduced a new product with a low price point and significant customer demand. The auditor would...
-
Solve each equation. 3Vx 12V/2x + 2 -
-
Add or subtract as indicated. 46.88 - 13.45
-
Give the domain of each rational function using (a) Set-builder notation (b) Interval notation f(x) = 9x - 8x + 3 4x + 1
-
Decide whether to drop a product line (Learning Objective 4) Top managers of Video Avenue are alarmed by their operating losses. They are consid ering dropping the VCR-tape product line. Company...
-
Dropping a product line (Learning Objective 4) Suppose Kelloggs is considering dropping its Special-K product line. Assume that dur ing the past year, Special-Ks product line income statement showed...
-
Determine product mix for retailer (Learning Objective 5) Vivace sells both designer and moderately priced fashion accessories. Top manage ment is deciding which product line to emphasize....
Study smarter with the SolutionInn App