ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(frozenset([1, 2]) == {1, 2}, {frozenset([1]): 'x'}[frozenset([1])])
  1. A. False x
  2. B. True None
  3. C. False KeyError
  4. D. True x

Correct answer: D. True x

A frozenset compares equal to a set with the same elements, and it is hashable, so it can be a dict key that is looked up again.

More Python Programming questions

Exams that ask this topic