ProgrammingHardTCS NQT · Infosys pattern

What is printed?

What is printed?
s1 = {1, 2, 3}
s2 = {2, 3, 4}
print(s1 - s2, s1 | s2, s1 & s2)
  1. A. {1} {1,2,3,4} {2,3}
  2. B. {4} {1,2,3,4} {2,3}
  3. C. {1} {2,3} {1,2,3,4}
  4. D. {1,4} {1,2,3,4} {2,3}

Correct answer: A. {1} {1,2,3,4} {2,3}

- is set difference (elements only in s1: {1}). | is union ({1,2,3,4}). & is intersection ({2,3}).

More Python Programming questions

Exams that ask this topic