Search for question
Question

Question #4 Using Python's list and dictionary data structures, write the code for a user-defined function called dot product that accepts a dictionary containing 'n' equal length one-dimensional lists such that

each list is stored using a unique key. You may assume there are a minimum of 2 keys in the dictionary, but there may be 3, 4, 10, 1000, etc, or more keys. This function performs a dot product multiplication of ALL lists in the dictionary and returns the result. In mathematics, the dot product or scalar product is an algebraic operation that takes two equal-length sequences of numbers (usually coordinate vectors), and returns a single number. An example of a dot product of 2 lists [1, 2, 3] and [6, 7, 8] would be: [1, 2, 3] [6, 7, 8] 1 * 6+ 2 * 7+ 3*8 = 44 The function prototype MUST be: def dot_product (d) :

Fig: 1