Suppose u and v both denote sets in Python. Under what condition can we guarantee that u|v == u^v?
a) The sets u and v should be disjoint.
b) The set v should be a subset of the set u
c) The set u should be a subset of the set v
d) This is true for any u and v.
Answer : a) The sets u and v should be disjoint
For two discrete sets u and v, the
| operator indicates the union. Union of two sets is a set containing all the elements from both two sets. For two sets u and v, ^ is the symmetric difference. It will give a set with elements in either u or v but not both. Therefore, these operators return an equal result if two sets u and v don’t have any common element, i.e, they are disjoint. In other words, they shouldn’t have any intersection.