1. Implement the function dict_intersect, which takes two dictionaries as parameters d1 and d2, and returns a new dictionary which contains only those keys which appear in both d1 and d2, whose values are a tuple of the corresponding values from d1 and d2.
E. g., dict_intersect ({'a': 'apple', 'b': 'banana'}, {'b': 'bee', 'c': 'cat'}) should return {'b': ('banana', 'bee') }
2. Implement the function consolidate, which accepts zero or more sequences in the star parameter seqs, and returns a dictionary whose keys consist of values found in those sequences, which in turn map to numbers indicating how many times each value appears across all the sequences.
E. g., consolidate ([1,2,3], [1,1,1], [2,4], [1]) should return the dictionary {1: 5, 2: 2, 3: 1, 4: 1}.
+5
Answers (1)
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “1. Implement the function dict_intersect, which takes two dictionaries as parameters d1 and d2, and returns a new dictionary which contains ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Home » Computers & Technology » 1. Implement the function dict_intersect, which takes two dictionaries as parameters d1 and d2, and returns a new dictionary which contains only those keys which appear in both d1 and d2, whose values are a tuple of the corresponding values from d1