 # My question related to set data type

example 1)

set().isdisjoint(set())---->True

example 2)
set().issuperset(set())----->True

How both are same if empty (set()) is disjoint of another empty (set()) it means both are different but in example 2 empty (set()) is a superset of another empty( set()) set How?
plz explain.

Hello Akshay,

Let’s have a look at the documentation:

`isdisjoint` ( other )

Return `True` if the set has no elements in common with other . Sets are disjoint if and only if their intersection is the empty set.

The rule here is ‘no elements in common’, and `set()` has no elements in common with itself: There are no elements in `set()` that are also in `set()`. (Due to the fact that there are no elements in `set()` at all).

The alternative definition ‘if and only if their intersection is the empty set’ makes it even more explicit that `set().isdisjoint(set())` should be `True`.

`issuperset` ( other )
`set >= other`
Test whether every element in other is in the set.

Is every element in `set()` also in `set()`? Absolutely: `set()` has no elements which aren’t also in `set()`. (And of course every set is its own super- and subset)

1 Like

Two sets are disjoint if they have no elements in common.

``````a = set()
b = set()
``````

Are there any elements that are in both a and b? No. Then they are
disjoint.

The superset question is a bit more subtle.

The definition of “superset” used by Python includes equality. (Some
mathematicians define superset to be strict and exclude equality.) So
to Python, a set a is a superset of b if every element of b is in a.
Another way to answer it is to ask, is there any element of b not in
a? No. Then every element must be in a, and so a is a superset of b.

We can do the disjoint and superset tests another way. Sets a and b are
disjoint if both of these are False:

``````any(el in a for el in b)
any(el in b for el in a)
``````

which they are. We can do the superset test `a.issuperset(b)` like this:

``````all(el in a for el in b)
``````

which is True.

Both of these are examples of a vacuous truth:

thank you sir

thank you so much sir