23.7. Chapter Assessment¶
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.
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.
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.
Use list comprehension to create a list called lst2
that doubles each element in the list, lst
.
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).
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.
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.