Quiz #7

Hello everyone!

I’m glad to tell you that I finished the quiz #7 and as every quiz I want to share it with you.

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).

Example. If the input is [2,4,5,6] and [1,2,3,4] the result will be 49 since (2*1)+(4*2)+(5*3)+(6*4) = 49

First of all, let me explain you what is the dot product.

dot

(https://www.mathsisfun.com/algebra/vectors-dot-product.html)

 

So, here is the code of the dot product:

2016-04-24 (1)

dot1

First, I create the function of the dot product wich make the product of the numbers depending in which site of the list the number is.

Then in the main function I ask how many numbers the list is going to have then the user type those numbers.

It is not a difficult code because we only use typical arranges, for loops, accumulators. If you can see my past post and study it, you will be able to make this without problems, remember to practice and do it by your own.

It wasn’t difficult but if you need more info you can go to this site which help me a lot.

Here is the code!

 

Thank you for visit my blog and see you in next post😉

 

Top image: flickr photo by Kaboedel https://flickr.com/photos/nerina/268955686 shared under a Creative Commons (BY-NC) license

 

 

 

 

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