🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)
  1. A.{'pen': 10, 'book': 50, 'bag': 300}
  2. B.{'pen': 12, 'book': 50, 'bag': 300}
  3. C.{'pen': 12, 'bag': 300}
  4. 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 →