CBSE Class 11 Informatics Practices Question 3 of 66

Dictionary — Question 3

Back to all questions
3
Question

Question 3

Assertion (A): The popitem() method can be used to delete elements from a dictionary.

Reasoning (R): The popitem() method deletes the last inserted key-value pair and returns the value of deleted element.

  1. Both A and R are true and R is the correct explanation of A.
  2. Both A and R are true but R is not the correct explanation of A.
  3. A is true but R is false.
  4. A is false but R is true.
Answer

Both A and R are true and R is the correct explanation of A.

Explanation
The popitem() method in Python is used to delete elements from a dictionary. It returns and removes the last inserted key-value pair from the dictionary.