= {'a':'b', 'c':'d', 'e':'f'}
dict_data = {'c', 'e'}
set_data
swap(dict_data, set_data)print(dict_data) # {'a': 'b', 'd': 'c', 'f': 'e'}
= {23:24, 110:120, 50:45, 70:50, 57:1}
dict_data = {23, 110, 57}
set_data
swap(dict_data, set_data)print(dict_data) # {50: 45, 70: 50, 24: 23, 120: 110, 1: 57}
= {23:24, 110:120, 50:45, 70:50, 57:1}
dict_data = {100}
set_data
swap(dict_data, set_data)print(dict_data) # {23:24, 110:120, 50:45, 70:50, 57:1}
Module 14 Assignments
Short Project 11
Due date: Dec 10, 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 27
Due date: Dec 10, Tuesday at 7pm
Write a Python function that does the following:
- Its name is
swap
- It takes two arguments: a dictionary and a set
- It swaps the key and value for all of the keys that exist in the dictionary that also exist in the set
- It does not return anything
Test cases:
Name the program swap_structures.py
. Make sure that gradescope gives you the points for passing the test case.
Programming Problem 28
Due date: Oct 8, Tuesday at 7pm
Write a Python function that does the following:
- Its name is
get_elements
- It two arguments: a
dictionary
with strings as keys and integers as values, and an integern
- It returns a list containing all of the values who fall into at least one of these three categories:
- The corresponding key starts with an upper-case letter
- The corresponding key ends with an upper-case letter
- The value is greater than or equal to the second parameter integer
Test cases:
= {'Alpha':10, 'bravo':25, 'charliE':15, 'dELTa':2}
data print( get_elements(data, 12) ) # [10, 25, 15]
Name the program get_specific.py
. Make sure that gradescope gives you the points for passing the test case.