Questions for Jeremiah’s concept map on python dictionaries.
- Multiple choice question.
Consider the following two lines of python code.
world_cup = {‘favorites’: [‘Brazil’, ‘Spain’, ‘Germany’], ‘host’: ‘Brazil’, ‘months’: [‘June’,’July’] }
list_to_print=[world_cup [‘months’] [0], world_cup [‘host’] [1], world_cup [‘favorites’] [2]]
Question 1:
What is the value of list_to_print?
A. [ [‘June’, ‘July’], ‘Brazil’, [‘Brazil’, ‘Spain’, ‘Germany’] ]
B. [‘June’, ‘r’, ‘Germany’]
C. [‘June’, ‘Brazil’, [‘Brazil’,’Spain’]]
D. [ ‘J’, ‘r’, ‘a’ ]
Question 2
Define a new dictionary Summer_2014. Summer_2014 should have two keys. One key should be named ‘sports’ and the value of the key should be the dictionary *world_cup *(as defined in question 1). A second key should be named ‘number_of_months’ and the value should be the integer 3.