ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
s = {1, 2, 3}
t = {3, 4}
print(s | t, s & t, s - t, s ^ t, s >= {1, 2})
  1. A. {1, 2, 3, 4} {3} {1, 2, 4} {1, 2, 4} True
  2. B. {1, 2, 3, 3, 4} {3} {1, 2} {4} True
  3. C. {1, 2, 3, 4} {3} {1, 2} {1, 2, 4} True
  4. D. {1, 2, 3, 4} {3} {1, 2} {1, 2, 4} False

Correct answer: C. {1, 2, 3, 4} {3} {1, 2} {1, 2, 4} True

| is union, & intersection, - difference (in s but not t), ^ symmetric difference (in exactly one), and >= tests superset.

More Python Programming questions

Exams that ask this topic