Activities: Week 7 (this is the week that includes the Mon-Tues of Fall Break)

Your next DYU, Demonstrate Understanding 6, is due October 29 to give you time to get readjusted from the midterm, but you may get started on it at any time! You’ve already done all of the readings necessary to complete it.

Problem Set

Write code to sort fall_list alphabetically and save the result in the variable sorted_fall_list.

Write code to do two things: (a) sort the list food_amounts by the value of each dictionary’s key "sugar_grams", and save the result in a variable sorted_by_sugar.

(b) Net carbohydrates for each dictionary data structure can be found by subtracting the value associated with the key "fiber" from the value associated with the key "carbohydrate". Sort this list of dictionaries by the value of each’s net carbohydrates, in order from the most to the least, largest -> smallest, and save the result, the properly sorted list, in a variable called sorted_net_carbs.

HINT: You’ll at least need to pass a function to the key parameter of the sorted function to solve (a) AND to solve (b) – but for each part, you could solve it in a single line of code.

Use a for loop to print the second element of each tuple in the list new_tuple_list.
We have provided a nested list in the variable nl. Write code to accumulate a list containing the second (as humans count) element of each sub-list and save it in a variable second_elems.
Next Section - Activities: Week 8