🎙 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 1 of 15

What does this print? (code)

What does this print?

d = {"a": 1, "b": 2}
d["a"] = 5
print(d["a"] + d["b"])
  1. A.3
  2. B.7
  3. C.6
  4. D.Error
Answer & explanation

Correct answer: 7

d["a"] becomes 5, so 5 + 2 = 7.

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 →