Quiz 7

This quiz in fact, it’s one of the things I do on physics class. Here are the instructions:

“Create a function called dot_product that receives two lists of numbers (say list1 and
list2). The function returns what is the dot product of the two lists.

For full marks, if the lists are not the same size, then the function should return the
special value of NaN (which represents not a number).”

Captura de pantalla 2016-05-06 a las 9.32.51

I created two lists with arrays. And then the dot_product functions works with the formula s (for sum) –> s = s + (list1 [i] * list2 [2]); That inside of a for loop.

It was very easy, because of I know the formula from my physics class.

Here’s my GitHub if you want the code.

If you didn’t understand the dot product, for any reason, here’s a link that explains that topic.

CC BY-SA 4.0 Quiz 7 by antonioangelm is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.