set operation fixes

This commit is contained in:
lukew3
2020-10-21 14:19:16 -04:00
parent 807114b782
commit b5b61cd08f
3 changed files with 100 additions and 95 deletions

View File

@@ -97,3 +97,4 @@ from .definite_integral import *
from .is_prime import *
from .bcd_to_decimal import *
from .complex_to_polar import *
from .set_operation import *

View File

@@ -10,12 +10,15 @@ def set_operation(minval=3, maxval=7, n_a=4, n_b=5):
a.append(random.randint(1, 10))
for i in range(number_variables_b):
b.append(random.randint(1, 10))
a=set(a)
b=set(b)
problem = "Given the two sets a=" + str(a) + " ,b=" + str(b) + ".Find the Union,intersection,a-b,b-a and symmetric difference"
solution = "Union is " + str(a.union(b)) + ",Intersection is " + str(a.intersection(b)) + ", a-b is " + str(a.difference(b)) + ",b-a is " + str(b.difference(a)) + ", Symmetric difference is " + str(a.symmetric_difference(b))
a = set(a)
b = set(b)
problem = "Given the two sets a=" + \
str(a) + " ,b=" + str(b) + ".Find the Union,intersection,a-b,b-a and symmetric difference"
solution = "Union is " + str(a.union(b)) + ",Intersection is " + str(a.intersection(b)) + ", a-b is " + str(
a.difference(b)) + ",b-a is " + str(b.difference(a)) + ", Symmetric difference is " + str(a.symmetric_difference(b))
return problem, solution
setoperations = Generator("Union,Intersection,Difference of Two Sets", 93,
set_operation = Generator("Union,Intersection,Difference of Two Sets", 93,
"Union,intersection,difference",
"aUb,a^b,a-b,b-a,", set_operation)