Module 12 Assignments

Short Project 10

Due date: Nov 26, Tuesday at 7pm

Short Programming projects are submitted during our weekly 45-minute in-person lab sessions. Each lab sessions is guided by two TAs. The instructions for the short project will be available only during the lab sessions. To schedule your lab session go to the weekly lab session spreadsheet.

Programming Problems

Programming Problems should be submitted to gradescope.

Programming Problem 23

Due date: Nov 26, Tuesday at 7pm

Write a Python function that does the following:

  1. Its name is differences
  2. It takes two sets as arguments: set_1 and set_2
  3. It calculates and returns the number of elements that are different (not in common) between the two parameter sets
  4. It returns an integer with the number of different elements

Test cases:

print( differences({1, 2, 3}, {2, 3, 4, 5}) ) # 3
print( differences({'john', 'mark', 'paul'}, {'john', 'mark'}) ) # 1

Name the program differences.py. Make sure that gradescope gives you the points for passing the test case.

Programming Problem 24

Due date: Nov 26, Tuesday at 7pm

Write a Python function that does the following:

  1. Its name is has_duplicate
  2. It takes a single list as argument
  3. It returns True if the list contains any duplicate values, False if all values are unique

Test cases:

print( has_duplicate([]) ) # False
print( has_duplicate([1, 2, 3, 1]) ) # True
print( has_duplicate([1, "a", "b", 4, 5]) ) # False
print( has_duplicate([1, "a", "a", 2, 3, 4]) ) # True

Name the program detect_duplicates.py. Make sure that gradescope gives you the points for passing the test case.