Page 1 of 1

IN PYTHON! examine the incomplete program. write code below the "#write code here" keyword. use set of operations to cre

Posted: Sat May 14, 2022 7:35 pm
by answerhappygod
IN PYTHON! examine the incomplete program. write code below the "#write code here" keyword. use set of operations to create new sets a and b. the output should be as follows and do not change any code:
OUTPUT:a = (2, 3, 4, 5}b= {4, 5, 6, 7}Set of elements that are in either a or b: {2, 3, 4, 5, 6, 7}Set of elements that are in both a and b: (4, 5}Set of elements that are in a but not in b: {2, 3}Set of elements that are in b but not in a: {6, 7}Set of elements that are in either a or b but not in both: {2, 3, 6, 7}CODE:a = (2, 3, 4, 5}b= {4, 5, 6, 7}union = set(intersection = set()a minus b = set()b_minus_a = set()sym_diff = set()# Write your code here:print('a =', a)print('b =', b)print("Set of elements that are in either a or b:', union)print("'Set of elements that are in both a and b:', intersection)print("Set of elements that are in a but not in b:', a minus_b)print ('Set of elements that are in b but not in a:', b_minus _a)print('Set of elements that are in either a or b but not in both:', sym_diff)
OUTPUT:
a = (2, 3, 4, 5}
b= {4, 5, 6, 7}
Set of elements that are in either a or b: {2, 3, 4, 5, 6, 7}
Set of elements that are in both a and b: (4, 5}
Set of elements that are in a but not in b: {2, 3}
Set of elements that are in b but not in a: {6, 7}
Set of elements that are in either a or b but not in both: {2, 3, 6, 7}
CODE:
a = (2, 3, 4, 5}
b= {4, 5, 6, 7}
union = set(
intersection = set()
a minus b = set()
b_minus_a = set()
sym_diff = set()
# Write your code here:
print('a =', a)print('b =', b)print("Set of elements that are in either a or b:', union)print("'Set of elements that are in both a and b:', intersection)print("Set of elements that are in a but not in b:', a minus_b)print ('Set of elements that are in b but not in a:', b_minus _a)print('Set of elements that are in either a or b but not in both:', sym_diff)
print('a =', a)
print('b =', b)
print("Set of elements that are in either a or b:', union)
print("'Set of elements that are in both a and b:', intersection)
print("Set of elements that are in a but not in b:', a minus_b)
print ('Set of elements that are in b but not in a:', b_minus _a)
print('Set of elements that are in either a or b but not in both:', sym_diff)