Checkpoint 10.2.1.
- d[5] = {1: 2, 3: 4}
- 5 is a valid key; {1:2, 3:4} is a dictionary with two keys, and is a valid value to associate with key 5.
- d[{1:2, 3:4}] = 5
- Dictionary keys must be of immutable types. A dictionary can’t be used as a key in a dictionary.
- d[’key1’][’d’] = d[’key2’]
- d[’key2’] is {’b’: 3, ’c’: "yes"}, a python object. It can be bound to the key ’d’ in a dictionary {’a’: 5, ’c’: 90, 5: 50}
- d[key2] = 3
- key2 is an unbound variable here. d[’key2’] would be OK.
Which of the following is a legal assignment statement, after the following code executes?
d = {'key1': {'a': 5, 'c': 90, 5: 50}, 'key2':{'b': 3, 'c': "yes"}}