Lab 9, Warmup

Worksheet link

Click for worksheet

Task 0: Warm up with dictionaries

You are given this dictionary:

backpack = {
      'money' : 10,
      'pencils' : 4,
      'umbrella' : True,
      'misc': ['lip balm', 'tissues', 'gum']

Task A: Fill in the blank below so that the following output results:

>>> ______________________________
['lip balm', 'tissues', 'gum']

Task B: Write a line of python code to add a calculator to the misc items in the backpack. How to see if the changes occurred? Come up with two different options:

Option 1:


Option 2:


Task C: Add a new key:value pair to the backpack dictionary that has key snack and value of one of your favorite snacks. Check the contents of your dictionary to make sure it is there (see options above).

Task D: What is printed when the following code executes:

for item in backpack:

Table of Contents