Checkpoint 15.7.1.
- 12
- 12 is associated with the key cat.
- 0
- The key mouse will be associated with the sum of the two values.
- 18
- Yes, add the value for cat and the value for dog (12 + 6) and create a new entry for mouse.
- Error, there is no entry with mouse as the key.
- Since the new key is introduced on the left hand side of the assignment statement, a new key-value pair is added to the dictionary.
What is printed by the following statements?
mydict = {"cat":12, "dog":6, "elephant":23}
mydict["mouse"] = mydict["cat"] + mydict["dog"]
print(mydict["mouse"])