Compare Lists

The purpose of these problems is to use loops, logic, and indexes to compare lists. The basic problem is constructing the order and types of comparisons. (We are not looking for the perfect, most efficient algorithm. We are looking for good enough.)

Project #1

Create two list of random integers. Find which values appear in one list but not the other.

Step #1:

Generate two random lists (A and B).

Step #2:

Compare the lists (A and B). Find the differences and the matches. When two values match they are no longer considered in further comparisons.

Step #3:

Display the differences for each list (A and B) and other statistics. Also display matches?

Design/Coding/Testing Hints:

  1. Sort the lists before comparing them.
  2. For each input list, create a list of differences? Or mark each value that has a match? Or mark each value that has no match?
  3. For development create "hand made" small lists for testing.

Project#2

Can Python sets be used in project #1? (The answer is no. Each element in a Python set must be unique. Project #1 can have lists with duplicate values.)

Eliminate all duplicate entries in the lists and do project #1 using Python sets.

FYI:

Project #3

Generate 4 lists. Display comparison statistics, including the number of times values appears in the lists. Ignore a value if it appears in all of the lists.

Generate N lists?