Master Mathematics.

Programming · Python, C & Pseudocode · Problem 5

Set operations in a loop

Consider the Python code

A={"this","that"}
B={"that","other"}
C={"other","this"}
while "other" in C:
    if "this" in A:
        A,B,C=A-B,B-C,C-A
    if "that" in B:
        A,B,C=C|A,A|B,B|C

At the end, which of the sets contains "this"?

  1. (A) Only A
  2. (B) Only B
  3. (C) Only C
  4. (D) A, C

Source: GATE DA