3. You should include the following definition in your module: Solve the followi
ID: 668659 • Letter: 3
Question
3. You should include the following definition in your module: Solve the following problems by defining appropriate relations. a. Include the following definitions in your code: Define the variable R1 above so that R1 is an equivalence relation over x1 and so that the following will evaluate to True: b. Include the following definitions in your code: Define the variable R2 above so that R2 is an equivalence relation over X2, and so that the following will evaluate to True: c. Include the following definitions in your code: Define the variable R3 above so that R3 is an equivalence relation over X3, and so that the following will evaluate to True: You must use a set comprehension to define R3. Solutions that use an explicitly defined set will receive no credit.Explanation / Answer
# declare and define all the required frozen sets first
# def = define in python after this def heading the contents or definitions will be indented
def X1():
items1 = ["a","b","c","d","e","f"]
varX1 = frozenset(items1) # var = variable hence varX1 = variable X1
# effectively varX1 becomes {"a","b","c","d","e","f"}
print(varX1)
def X2():
items2 = [0,1,2,3,4,5,6,7,8,9,10,11]
varX2 = frozenset(items2)
print (varX2)
def X3():
items3 = [set(range(0,50))]
varX3 = frozenset # var = variable varX3 = variable X3
print(varX3) # output will be from 0,1,2,3,4,5,6,7,...,...,upto 49
# alternatively the following syntax or usage will also work
# varX3 = frozenset([range(0,50)])
def R1():
varR1 = varX1
def R2():
varR2 = varX2
def quotient(X,R):
return {frozenset( {
y for Y in X
if (x,y) in R)
for x in X
# x in X means true if X == x
# in C format, if ( X == x) true;
# if (X<>x) false;
}
Explanation (Theory):
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.