ProgrammingHardCognizant GenC · TCS NQT

What is printed?

What is printed?
a = {1, 2, 3}
b = {3, 4}
print(a ^ b, a.issubset({1, 2, 3, 4}), sorted(a - b, reverse=True), b > {3})
  1. A. {1, 2, 4} False [1, 2] True
  2. B. {3} True [2, 1] False
  3. C. {1, 2, 4} True [2, 1] False
  4. D. {1, 2, 4} True [2, 1] True

Correct answer: D. {1, 2, 4} True [2, 1] True

^ gives the symmetric difference, issubset tests containment, and > means a proper superset. {3, 4} strictly contains {3}, so the last value is True.

More Python Programming questions

Exams that ask this topic