← Quiz: Python Dictionaries: all 15 questions
Quiz: Python Dictionaries · Question 11 of 15
What does this print? (code)
What does this print?
prices = {"pen": 10, "book": 50}
prices.update({"pen": 12, "bag": 300})
print(prices)
- A.{'pen': 10, 'book': 50, 'bag': 300}
- B.{'pen': 12, 'book': 50, 'bag': 300}
- C.{'pen': 12, 'bag': 300}
- D.An error
Answer & explanation
Correct answer: {'pen': 12, 'book': 50, 'bag': 300}
update() changes existing keys and adds new ones.
Can you get the rest right without peeking?
Take the timed Quiz: Python Dictionaries quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →