Question: PYTHON: 1. Write a function that takes in two dict data structures as input. Both dicts map str->int (the keys are strings and the values

PYTHON:
1. Write a function that takes in two dict data structures as input. Both dicts map str->int (the keys are strings and the values are integers). The function should compute a new dict which combines the two dicts by summing the values for the common keys. Keys that are not common should be left out. Use the following code to test your function, but remember that your function should for all str->int dict inputs, not just the test here.
my_dict_1 = {'a': 5, 'b': 12, 'c': 3, 'd': 9} my_dict_2 = {'b': 4, 'c': 9, 'd': 10, 'e': 16} combined_dict = get_combined_dict(my_dict_1, my_dict_2) print(combined_dict)
 

2. Take in a string from the user and pass it as input to a function. Have the function return a dict which keeps count of each letter (in lowercase) in the string, excluding spaces. Print out this dict. PYTHON: 1. Write a function that takes in two dict data structures
as input. Both dicts map str->int (the keys are strings and the

2. Write a function that takes in two dict data structures as input. Both dicts map str->int (the keys are strings and the values are integers). The function should compute a new dict which combines the two dicts by summing the values for the common keys. Keys that are not common should be left out. Use the following code to test your function, but remember that your function should for all str->int dict inputs, not just the test here. = = my_dict_1 {'a': 5, 'b': 12, 'c': 3, my_dict_2 {'b': 4, 'c': 9, 'd': 10, combined_dict = get_combined_dict(my_d print(combined_dict) = $ python script_2.py {'b': 16, 'c': 12, 'd': 19} 3. Take in a string from the user and pass it as input to a function. Have the function return a dict which keeps count of each letter (in lowercase) in the string, excluding spaces. Print out this dict. $ python script_3.py Enter a string: Hello World {'h': 1, 'e': 1, 'l': 3, 'o': 2, 'w': 1, 'r': 1, 'd': 1}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!