1.

If a is a dictionary with some key-value pairs, what does a.popitem() do?(a) Removes an arbitrary element(b) Removes all the key-value pairs(c) Removes the key-value pair for the key given as an argument(d) Invalid method for dictionaryThe question was posed to me in an interview for job.My doubt is from Dictionary topic in section Dictionary, Functions and Built-in Functions of Python

Answer» RIGHT option is (a) Removes an ARBITRARY element

Explanation: The METHOD popitem() removes a random key-value PAIR.


Discussion

No Comment Found

Related InterviewSolutions