Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Below, you will find two lists of functions that you may code. You will choose two functions from the first list ( i . e
Below, you will find two lists of functions that you may code. You will choose two functions
from the first list ie the "Set Construction" list and one function from the second list ie
the "Set Relations" list So you will be creating three functions in all. Note that all sets
will be represented by lists in Python with no repeated elements. Also note that there is
a way you can construct sets in Python without using lists. For this assignment,
you are not allowed to use this construction in any way.
Set Construction.
a Create a function called "intersect" whose inputs are two sets lists A and
and whose output is a set list that is the intersection of the two sets.
b Create a function called "union" whose inputs are two sets lists A and and
whose output is a set list that is the union of the two sets.
c Create a function called "difference" whose inputs are two sets lists A and
and whose output is a set list that is the set difference ie "setminus"
of the two sets.
d Create a function called "cartesianProduct" whose inputs are two sets lists
and and whose output is a set list that is the Cartesian product
of the two sets. Note that ordered pairs will be represented by lists with two
components.
Set Relations
a Create a function called "subset" whose inputs are two sets lists A and and
whose output is a Boolean value. The output is "True" if AsubeB and "False" if
b Create a function called "equal" whose inputs are two sets lists A and and
whose output is a Boolean value. The output is "True" if and "False" if
Note that even if the elements may be listed in a different order.
c Create a function called "element" whose inputs are a set list A and some object.
and whose output is a Boolean value. The output is "True" if xinA and "False"
if inA.
Make sure your function is well documented. You should have oneline comments using the
single line comments with # written in complete sentences that describe what each line of
code does. You may not import any packages to help you with your function.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started