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
-
(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,...
-
The units of an item available for sale during the year were as follows: Jan. 1 Inventory 40 units @ $92 each Mar. 10 Purchase 40 units @ $104 each Aug. 30 Purchase 20 units @ $108 each Dec. 12...
-
On January 1, 2019, Caswell Company signs a 10-year cancelable (at the option of either party) agreement to lease a storage building from Wake Company. The following information pertains to this...
-
Diagram the flow of payroll data within general accounting.
-
The following information is available for the employees of Webber Packing Company for the first week of January 2016: 1. Kayla earns $28 per hour and 1 times her regular rate for hours over 40 per...
-
Marcus is attending State University full time and is in his second year at university. He received a scholarship to help with his school expenses. The scholarship is $5,000 and is all used to pay...
-
Determine Vo and ID for the network of Fig. 2.158. Si Si
-
Use the Algebra of Limits and Standard Sequences to evaluate: 12n3 - 4n2 + n+ 2 lim (1) 5n3 + 10n + 5 n-00 10n3 5n2 + 4 (2) lim n4 + 5n3 + 10n n-00 2V5 nv5 lim (3) 5n2 5n n-00 lim (n-2n) (4)
-
In the bond market, we find the following Treasury bonds and their prices. Bond price Maturity Face value Coupon rate $980 2 years $1,000 10% a) Compute the YTMs for the above three bonds. $98 1...
-
Suppose three portfolios built using three securities are as follows: portfolio #1 portfolio 2 portinio 3 $11.60 0,20 0.30 He 0.40 0.00 0.20 0.00 0.30 0.30 mean 0.1300 0.1220 01710 where w, W, and w,...
-
Calculate the volatility of the stock returns of California REIT and Brown Group with the spreadsheet data . How do the volatilities of the individual stock returns compare to that of the Vanguard...
-
1. Assume Bed Bath & Beyond acquires 100 percent of Pier 1, and that the transaction takes place at fiscal year end 2001. Prepare a consolidating balance sheet to reflect the acquisition at time of...
-
You borrowed $2,500 from the bank at a rate of 6% compounded quarterly. You will repay the loan back over 3 years with payments every three months. Show the original principal balance and complete...
-
Are there differences in the number of demerit points men and women attain from driving offences? The following data was collected on the mean points held by a group of 31 men and 34 women. Count Men...
-
Design a circuit which negative the content of any register and store it in the same register.
-
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
-
Using the results of Problem 2.6, determine the invariants \(U_{i}\) and \(V_{i}\) for the AS/3501 lamina, where \(i=1,2,3,4\). Problem 2.6 Find all components of the stiffness and compliance...
-
Show how the Mohr's circles in Figure 2.17 can be used to interpret the transformed lamina stiffness \(\bar{Q}_{12}\). FIGURE 2.17 40 'n Q11 In- n> Q11 20 -U-
-
Using the results of Problem 2.6 or Problem 2.16, compare the transformed lamina stiffnesses for AS/3501 carbon/epoxy plies oriented at \(+45^{\circ}\) and \(-45^{\circ}\). Problem 2.6 Using the...
Study smarter with the SolutionInn App