Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Coding Practice #1: Due midnight, September 29

file needed = None

Please answer the questions below in a Jupyter notebook. You can modify this notebook by adding cells with your answers. When you are finished, please upload and submit the completed notebook to Canvas

Reminder: my office hours are Mondays 2-3PM & Wednesdays 9-10AM CT in 7434 Soc Sci. Minnie's are Mondays 1:15-2:15PM & Wednesdays 2:30PM- 3:30PM CT in 6473 Soc Sci.

Feel free to discuss the coding practice with your classmates, but the work you turn in should be your own.

Cite any code that is not yours: https://canvas.wisc.edu/courses/374352/pages/citing-code (https://canvas.wisc.edu/courses/374352/pages/citing-code)

Exercise 1: Last, First

Replace 'Last, First' above with your actual name. Enter it as your last name, first name.

Exercise 2: Warm-ups

1. For each of the following objects, enter the type of the object next to it. Put your answers in bold italics to make them easy for Minnie to find. A.  770

B.   (770, 'Hello')

C.  x = ['hello', 770, [5.2, ('section', [4])], ['loop', 5, ['if', 'else', 3]], 10.999]

D.  x[2][1]

2. Write code that modifies the below list of the Beatles' band members, replacing Pete Best with Ringo Starr. Print the resulting list.

beatles = ['John Lennon', 'Paul McCartney', 'George Harrison', 'Pete Best']

3. Write code that iterates through the list you created in 2. to printout the sentence "The Beatles were John Lennon and Paul McCartney and George Harrison and Ringo Starr."

4. You are given the  data dictionary below (source: KFF (https://www.healthsystemtracker.org/chart-collection/u-s-spending-healthcare-changed-time/)). Notice that the health spending data are stored as strings. Fix  data by replacing the strings with floats and then print the  dict . Use a loop or a list

comprehension.

data = {'year' : [1990, 2000, 2010], 'health_spend' : ['718.8', '1365.7', '2589.4']}

5. We went through the example below in python_basics_3.ipynb. Rewrite the code so that it doesn't use  while . You may use  if ,  for ,  else , etc.

count = 0

while count < 3:

if count < 2:

print("Hip,")

else :

print("Hooray!")

count += 1

Exercise 3: U.S. Exports

The next cell has a dictionary with nominal exports of goods (in millions of dollars) from the United States to all other countries in 2017.

Run the cell below to read the dictionary into memory.

In  [6]:

us_exports_2017 = {'Argentina': 9585.957928, 'Serbia': 125.604552, 'Bulgaria': 381.490292, 'Bangladesh': 1473.961033,

'Sierra Leone': 79.185252, 'Guyana': 377.349484, 'Turkey': 9741.491909, 'Syrian Arab Republic': 6.961023,

'Saint Vincent and the Grenadines': 81.348131, 'Eritrea': 5.021254, 'Kosovo': 10.070786, 'Bermuda': 693.65006,

'Zimbabwe': 39.926035, 'Suriname': 359.542397, 'Uganda': 107.869624, 'Palau': 19.432665, 'Guinea': 103.022431,

'Heard Island and Mcdonald Islands': 0.125829, 'Mongolia': 82.192362, 'Botswana': 93.045279, 'Cameroon': 158.845783, 'Ecuador': 4820.700634, 'Falkland Islands (Malvinas)': 0.482089, 'Iceland': 399.258756, 'South Korea': 48326.408702, 'Hungary': 1888.233492, 'Comoros': 1.375097, 'Malta': 293.009573, 'Luxembourg': 1078.074731, 'Tonga': 16.719457,

'Tanzania; United Republic of': 145.242068, 'Liberia': 138.340637, 'Mali': 62.01555, 'Algeria': 1059.840617,

'South Africa': 5020.062464, 'Kyrgyzstan': 26.066859, 'Swaziland': 24.073435, 'Central African Republic': 11.178603, 'Andorra': 3.285167, 'Seychelles': 15.488847, 'Other Countries': 0.0, 'Cook Islands': 5.243873,

"Lao People's Democratic Republic": 25.67166, 'Ghana': 859.971235, 'Malaysia': 12964.461912,

'Micronesia (Federated States of)': 44.827548, 'Indonesia': 6863.831289, 'Tajikistan': 17.911115, 'Gambia': 39.235769, 'Thailand': 10991.613094, 'Cape Verde': 9.146393, 'West Bank': 2.19236, 'Sri Lanka': 336.25559,

'Burma (Myanmar)': 211.368799, 'Lebanon': 1221.529041, 'Poland': 4523.318939, 'Austria': 4275.26315,

'Panama': 6301.303156, 'Lithuania': 609.272207, 'Hong Kong': 39939.130227, 'Kenya': 454.453344, 'Netherlands': 41510.332962 'Dominican Republic': 7827.520352, 'Cayman Islands': 885.800982, 'Reunion': 8.376879, 'Belarus': 72.668182,

'Burundi': 8.13276, 'Nigeria': 2170.069073, 'Martinique': 168.255979, 'Equatorial Guinea': 111.93615, 'Vatican City': 1.146

'Taiwan': 25729.504439, 'Georgia': 382.865271, 'Aruba': 966.305683, 'Lesotho': 1.901616, 'Colombia': 13312.122946, 'Curacao': 692.167798, 'Cuba': 291.276873, 'French Southern Territories': 2.842721, 'China': 129893.586716,

'Norway': 5453.37072, 'Svalbard and Jan Mayen Island': 1.986719, "Côte d'Ivoire": 319.964133, 'Uruguay': 1599.284155, 'Montserrat': 9.708109, 'Madagascar': 53.367175, 'Vanuatu': 7.762425, 'Bhutan': 34.892754, 'Greenland': 9.884715,

'Kuwait': 5143.414006, 'Iraq': 1204.721644, 'Senegal': 207.93405, 'Ukraine': 1787.9993, 'Haiti': 1410.575337,