CBSE Class 12 Computer Science Question 7 of 42

Solved 2024 Sample Question Paper CBSE Class 12 Computer Science (083) — Question 7

Back to all questions
7
Question

Question 7

Which of the following will delete key-value pair for key = “Red” from a dictionary D1 ?

  1. delete D1("Red")
  2. del D1["Red"]
  3. del.D1["Red"]
  4. D1.del["Red"]
Answer

del D1["Red"]

Reason — The syntax to delete a key-value pair from a dictionary in Python is : del dictionary_name[key]. Therefore, according to this syntax, del D1["Red"] is correct statement."