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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply