Reverse Instructional Design: python dict

Jul 26, 2014 • Clare Sloggett

**Multiple choice: **

Consider the following Python code, which creates and manipulates a dictionary:

favourite_things = {'blue':'sky', 'red':'scarf', 'yellow':'daffodils'}<br /> favourite_things['blue'] = 'ocean'<br /> del favourite_things['yellow']<br /> print sorted( favourite_things.values() )

What will be printed if you run this code?

a) ['blue', 'daffodils', 'ocean', 'red', 'scarf', 'sky', 'yellow']
b) ['blue', 'daffodils', 'ocean', 'red', 'scarf']
c) ['ocean', 'scarf']
d) ['blue', 'red']
e) ['ocean', 'scarf', 'sky']

Written question:

Write down the code you would use to add a new key ‘green’ to the dictionary and give it the value ‘emeralds’.