Module 13 Assignments

Short Project 11

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 in Short Project Dates and Instructions.

Programming Problems

Programming Problems should be submitted to gradescope.

Programming Problem 25

Due date: Tuesday, April 22, 2025 at 9pm

Write a Python function that does the following:

  1. Its name is sum_nums
  2. It takes two arguments: a list of list (2D list) of integers and n an integers
  3. It iterates through all of the numbers, and sum all of the ones whose value is less than n
  4. It returns the sum

Test cases:

print( sum_nums([[2, 12, 2], [12, 5, 100, 9]], 10) ) # 18
print( sum_nums([[2, 12, 2], [10, 5, 10, 9]], 10) ) # 18
print( sum_nums([[2, 12, 2], [10, 5, 10, 9]], 0) ) # 0
print( sum_nums([], 10) ) # 0

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

Programming Problem 26

Due date: Tuesday, April 22, 2025 at 9pm

Write a Python function that does the following:

  1. Its name is longest_string
  2. It takes one argument: a list of dictionaries
  3. The keys in each dictionary could be of various types, but you may assume that the values will be strings
  4. It returns the longest string value from all of the dictionaries in the list

Test cases:

data = [{'a':'horse', 'b':'caterpillar'}, {'a':'camp', 'c':'joker'}]
print( longest_string(data) ) # caterpillar

data = [{1:'abc', 5:'onetwothree'}, {2:'abcd'}, {7:'one two three'}]
print( longest_string(data) ) # one two three

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