- [Narrator] In this self check exercise,
we want you to use the mathematical set operators
to combine the two sets that we're showing you
as part of the problem statement here,
and produce the results shown
in parts A through D down below.
So using the operators that you just learned about,
why don't you pause the video and give that a shot,
then come back here for the answers?
Okay, let's talk about the possibilities here.
So, for part A here,
the resulting set should contain only 30.
And if you take a look here,
you'll see that 10 and 20 are common
between these two sets.
Five is not in common,
but since the result only has 30 in it,
it appears what we're trying to do here
is calculate the difference between the sets.
So when I subtract the right hand set
from the left hand set,
the set difference is going to consist of
the elements in the left that are not in the right,
and the only such element in this case is 30.
So let me reveal my answer.
Here is the minus operation for set difference,
and if I execute that,
indeed I get 30.
Now in this next one,
we get five, 15, and 30,
and if you look carefully at all the values here,
10 and 20 are common between these two sets,
but five and 15 on the right side
and 30 on the left side
are differences between the two sets.
So this appears to be a symmetric difference.
And if we go ahead and take a look
at this next solution here,
we're using the symmetric difference operator,
and indeed we do get the result specified in part B.
Now if you look at part C here,
the resulting set has everything
that's unique to both of these sets,
so this appears to be a union operation.
So I'll go ahead and reveal
the use of the union operator here,
and indeed we get the values shown in part C.
And finally, we want to do an intersection as well,
and if you look at part D's answer,
the intersection of these two sets
are the values 10 and 20,
which are in both the left and the right operand.
So just to demonstrate the intersection
with the ampersand operator there,
you can see that indeed we get 10 and 20 as our result.