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.

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Salir /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s