Question: Python Please Function Name: sum_of_list_values Parameters: two dictionaries(d1, d2) Returns: an dictionary Description: Write a Python function sum_of_list_values that takes two dictionaries(d1, d2) as parameters,

Python Please

Python Please Function Name: sum_of_list_values Parameters: two dictionaries(d1, d2) Returns: an dictionary

Function Name: sum_of_list_values Parameters: two dictionaries(d1, d2) Returns: an dictionary Description: Write a Python function sum_of_list_values that takes two dictionaries(d1, d2) as parameters, and returns a combined dictionary constructed using the following rules. NOTE: the type of d2 and d1 are dict of {v:list of int}; for example: d1 = {1:[2], 4:[5, 6]) Return the dictionary where: each key is a key that is in both d1 and d2. the value associated with each key in the new dictionary is the sum of all the integers associated with that key in d1 and d2. Sample Function Call: dl = {1:[2], 4:[5, 6]} d2 = {4: [8]} sum_of_list values (di, d2) Expected Return: {4:19) NOTE: The exact order of key-value pairs is not important. We will use unit-tests to verify correctness. 296528.1655254.qx3zqy7 LAB ACTIVITY 13.56.1: Sum of List Values (Functions - Medium) 0/11 main.py Load default template... 1 #Define your function here 2 #NOTE: Feel free to add print statements to your code to help you visualize, 3# and call the function with the sample inputs. 4 # Testing for this question ignores printed values 7 8 if __name__ == "__main__": 9 assert sum_of_list_values({1:[2], 4:[5, 6]}, {4:[8]}) - {4:19} 10 assert sum_of_list_values({}, {'a': [1], 'X':[3], 'z':[22]} ) == { }

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!