13.8. Chapter Assessment¶
Create a tuple called olympics
with four elements: “Beijing”, “London”, “Rio”, “Tokyo”.
The list below, tuples_lst
, is a list of tuples. Create a list of the second elements of each tuple and assign this list to the variable country
.
Before you keep reading...
Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
With only one line of code, assign the variables city
, country
, and year
to the values of the tuple olymp
.
Define a function called info
with five parameters: name, gender, age, bday_month, and hometown. The function should then return a tuple with all five parameters in that order.
Given is the dictionary, gold
, which shows the country and the number of gold medals they have earned so far in the 2016 Olympics. Create a list, num_medals
, that contains only the number of medals for each country. You must use the .items() method. Note: The .items() method provides a list of tuples. Do not use .keys() method.