197k views
1 vote
What is the output after the following statements are executed:

>>> d = {}
>>> d["susan"] = 50
>>> d["jim"] = 45
>>> d["joan"] = 54
>>> d["susan"] = 51
>>> d["john"] = 53
>>> print(d)

User Espeed
by
8.0k points

1 Answer

4 votes

Final answer:

The dictionaries' key-value pairs are shown after executing the given statements.

Step-by-step explanation:

The output will be a dictionary with the following key-value pairs:

  • 'susan': 51
  • 'jim': 45
  • 'joan': 54
  • 'john': 53

The initial empty dictionary d is first created. Then, key-value pairs are added to the dictionary, with the keys being the names and the values being the numbers. When a key is assigned a new value, the old value is overwritten. Finally, the dictionary d is printed, showing the updated key-value pairs.

User Jaminto
by
7.8k points