A dictionary is declared as: D = {10: "A", 25: "B", 32: "C", 54: "D"} Which of…

2023

A dictionary is declared as: D = {10: "A", 25: "B", 32: "C", 54: "D"} Which of the following is incorrect?

  1. A.

    D[20] = "E"

  2. B.

    D[30] += 20

  3. C.

    D[32] += '*'

  4. D.

    D['X'] = 100

Attempted by 1719 students.

Show answer & explanation

Correct answer: B

D[30] does not exist in the dictionary. Using += on a non-existent key raises a KeyError.

Explore the full course: Rssb Senior Computer Instructor