13.8 Chapter Assessment

From Foundations of Python ProgrammingGNU FDL 1.3Original pagePython1 class period5 exercises5 graded tests

README.md

13.8 Chapter Assessment

Exercise 1

Create a tuple called olympics with four elements: "Beijing", "London", "Rio", "Tokyo".

Open the 01 folder and edit main.py. Run Tests checks it.

Exercise 2

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.

Open the 02 folder and edit main.py. Run Tests checks it.

Exercise 3

With only one line of code, assign the variables city, country, and year to the values of the tuple olymp.

Open the 03 folder and edit main.py. Run Tests checks it.

Exercise 4

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.

Open the 04 folder and edit main.py. Run Tests checks it.

Exercise 5

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.

Open the 05 folder and edit main.py. Run Tests checks it.

For teachers

13.8 Chapter Assessment

Students read Foundations of Python Programming's “Chapter Assessment” in CS Room and work through its 5 Python coding exercises (5 graded).

  • Time: 1 class period
  • Tests: 5 in 5 graded exercises, set up for you when you import the lesson

Exercises

FolderGradingTests
01Autograded1
02Autograded1
03Autograded1
04Autograded1
05Autograded1