IT 210— Fundamentals of Programming — Lab 7 Solved

35.00 $

Category:

Description

5/5 - (1 vote)

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:

  1. Create a new set of all elements that are in setl or set 2, but not both.
  2. Create a new set of all elements that are in only one of the three sets set 1, set 2, and set 3.
  3. 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

Each member of the group must make a submission to D2L with your own name as a comment on line 1 and the name or names of other group members on the next line. If you do the lab solo, I will deduct 20 points. Submit a copy of the lab to the Lab 7 D2L dropbox not later than 11:59 pm Friday evening. Name your file Lab07.py.

  • Lab07-rppev2.zip