Question: how do I do this using python? Define the contains_keys_and values) function which is passed two dict objects as parameters, dict1 and dict2. The two

how do I do this using python?

how do I do this using python? Define the contains_keys_and values) function

Define the contains_keys_and values) function which is passed two dict objects as parameters, dict1 and dict2. The two parameter dictionaries both have corresponding values which are lists of elements (numbers or strings). The function return True if the following two conditions are met: .dict1 contains all the keys which are in dict2 (dict1 may contain extra keys), and the elements in all the corresponding value lists of dict2 are also elements in all the corresponding value lists of dict1 Note: when testing this part of the condition, the elements can be in any order and in any of the corresponding value lists, e.g., if one of the corresponding values lists of dict2 is [4, 2] and any one of the corresponding value lists of dict1 contains the element 4 and any one of the corresponding value lists of dict1 contains the element 2, this part of the condition is satisfied The function returns False in all other cases For example, the following code dict2 h print("1.", contains_keys_and_values (dictl, dict2)) dictl[4, 3] "d:[6, 2], "z": [, "t": [2, 23] dict2 ["z[2, 3, 6, 23], "a:[41 print("2.", contains_keys_and_values (dictl, dict2)) dictl "a: [6, 3], "p:1 dict2 {"a": [3, 6, 3], "p": [6, 1)) print("3.", contains-keys-and-values(dict 1, dict2)) dictl "a: [6, 3], "p:1 dict2 {"a": [3, 6, 3], "p": ["a"]} print("4.", contains_keys_and_values (dictl, dict2)) dictl[6, 3], "p": ['a'], "t": 's'1 dict2 ("a": [3, 6, 3], "p": ['a'], "s": ["a"]} print("5.", contains-keys-and-values(dict 1, dict2)) prints 1. True 2. True 3. False 4. False 5. False

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!