ProgrammingModerateInfosys · Accenture · Capgemini pattern

What is printed?

What is printed?
print({1, 2, 3} ^ {2, 3, 4}, {1, 2} <= {1, 2, 3})
  1. A. {1, 4} True
  2. B. {1, 4} False
  3. C. {1, 2, 3, 4} True
  4. D. {2, 3} True

Correct answer: A. {1, 4} True

^ is symmetric difference: the elements in exactly one of the sets, here {1, 4}. <= tests for subset, and {1, 2} is a subset of {1, 2, 3}, so it is True.

More Python Programming questions

Exams that ask this topic