23.7 Chapter Assessment
From Foundations of Python ProgrammingGNU FDL 1.3Original pagePython2 class periods7 exercises9 graded tests
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
01folder and editmain.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
02folder and editmain.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
03folder and editmain.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
04folder and editmain.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
05folder and editmain.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
06folder and editmain.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
07folder and editmain.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
| Folder | Grading | Tests |
|---|---|---|
01 | Autograded | 1 |
02 | Autograded | 1 |
03 | Autograded | 1 |
04 | Autograded | 1 |
05 | Autograded | 1 |
06 | Autograded | 1 |
07 | Autograded | 3 |