23.7 Chapter Assessment

From Foundations of Python ProgrammingGNU FDL 1.3Original pagePython2 class periods7 exercises9 graded tests

README.md

23.7 Chapter Assessment

Exercise 1

Write code to assign to the variable map_testing all the elements in lst_check while adding the string "Fruit: " to the beginning of each element using mapping.

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

Exercise 2

Below, we have provided a list of strings called countries. Use filter to produce a list called b_countries that only contains the strings from countries that begin with B.

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

Exercise 3

Below, we have provided a list of tuples that contain the names of Game of Thrones characters. Using list comprehension, create a list of strings called first_names that contains only the first names of everyone in the original list.

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

Exercise 4

Use list comprehension to create a list called lst2 that doubles each element in the list, lst.

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

Exercise 5

Below, we have provided a list of tuples that contain students' names and their final grades in PYTHON 101. Using list comprehension, create a new list passed that contains the names of students who passed the class (had a final grade of 70 or greater).

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

Exercise 6

Write code using zip and filter so that these lists (l1 and l2) are combined into one big list and assigned to the variable opposites if they are both longer than 3 characters each.

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

Exercise 7

Below, we have provided a species list and a population list. Use zip to combine these lists into one list of tuples called pop_info. From this list, create a new list called endangered that contains the names of species whose populations are below 2500.

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

For teachers

23.7 Chapter Assessment

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

  • Time: 2 class periods
  • Tests: 9 in 7 graded exercises, set up for you when you import the lesson

Exercises

FolderGradingTests
01Autograded1
02Autograded1
03Autograded1
04Autograded1
05Autograded1
06Autograded1
07Autograded3