Starting from:

$30

IT210- Fundamentals of Programming Lab 7 Solved

This program requires you to work in a group of two or three write Python code that implements problem R8_20, parts a, b, and c in your text on page 437. That problem is restated here:

Given three sets, set 1, set 2, and set3, write Python statements to perform the following actions:

a.     Create a new set of all elements that are in setl or set 2, but not both.

b.     Create a new set of all elements that are in only one of the three sets set 1, set 2, and set 3.

c.     Create a new set of all elements that are in exactly two of the sets set 1, set 2, and set 3.

Implementation comments:

                   You may find it useful to define a function whose definition starts: def makeSt r (collection) :

that returns a string containing all the elements of a collection (set, list, tuple, etc).

            I will test your program using only strings of characters

            The outputs should contain the characters in sorted order.

            For part b first find the elements that are only found in set 1, in set 2, in set 3, then combine these results

            For part c you will need to do three pair-wise intersections, an intersection of all three and then use union and difference to compute the resulting set.

            Discuss how to approach each of the parts with your team members.

A sample run of your program should look like this:

Enter a
string to be used as set 1: abcdefg
Enter a
string to be used as set2: cdefghijkt
Enter a
string to be used as set3: fghijklmnop
Part A :
abhij kl
Part B:
abmnop
Part C:
cdehij kl

More products