Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Initialize sets A and B A = { ' a ' , ' b ' , ' c ' , ' d ' ,

# Initialize sets A and B
A ={'a','b','c','d','e','f'}
B ={'c','d','f','h','j','k'}
print('A =', sorted(A))
print('B =',sorted(B))
print('')
#Block 1: computes and prints out the set A - B
AminusB = set()
for element in A: # this line runs through every element in A
if not(element in B): #A - B is the set of elements that are in A and are not in B
AminusB.add(element) # Add it AminusB every element in A if the element is also not in B
print('A - B =', sorted(AminusB))
print('')
#Block 2:
BminusA = set()
# put your code here to compute B minus A
print('B - A =', sorted(BminusA))
print('')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions