Question

In: Computer Science

I am not even sure what the question is for the problem below, but I have...

I am not even sure what the question is for the problem below, but I have highlighted what I think the question is further down:

Let v = (v1, v2) and w = (w1, w2) be vectors in 2 space.

The Scalar Product of v and whose notation is v (dot) w, is defined as follows: V (dot) w : = v1*w1 + v2 *w2

The scalar product (aka inner product, or dot product) Scalar product of 2 vectors in 2-space using 4 float parameters (the function scalarProduct 1)

ACTUAL QUESTION (I think ) - Code the following in Python:

Write a docstring; then write some test function calls; then implement the body of the function

Some test data: (1., 1.) · (2,3) = 5 (or, as a function call: scalarProduct1)

(1., 1., 2., 3.) (1.,1.) · (2,0) = 2

(1., 1.) · (0,2) =2

(1., 1.,) · (4,5) =23

Solutions

Expert Solution

#ScalarProduct function
#It takes two vectors as input arguments
#It returns sum as output

def scalarProduct1(vect1, vect2):
return sum(i*j for i,j in zip(vect1,vect2))

#defining vectors 1 and 2
vector1 = [2,3]
vector2 = [1,2]

print("Scalar Product of given vectors is : ")
#Calling function defined above to calculate the dot product.
print(scalarProduct1(vector1,vector2))

Attaching Screenshot

Feel free to ask any doubts, if you face any difficulty in understanding.

Please upvote the answer if you find it helpful


Related Solutions

I am stuck on this problem and I am not sure what the solution is. In...
I am stuck on this problem and I am not sure what the solution is. In C Write item.h and item.c. In item.h, typedef a struct (of type t_item) which contains the following information: t_item: char name[MAX_ITEM_NAME_STRING]; char description[MAX_ITEM_DESCRIPTION_STRING]; Make sure that MAX_ITEM_NAME_STRING and MAX_ITEM_DESCRIPTION_STRING are defined with suitable sizes in your item.h. Typical values are, 25 and 80, respectively. Add the following interface definition to item.h: int item_load_items(t_item items[], int max_items, char *filename); Returns the number of objects loaded...
I am working on this problem for the company AT & T and am not sure...
I am working on this problem for the company AT & T and am not sure how to start it. Draw a chart of the main inter-organizational linkage mechanisms (e.g., long -term contacts, strategic alliances, mergers) that your organization uses to manage its symbiotic resource interdependencies. Using resource dependence theory and transaction cost theory, discuss why the organization to manage its interdependencies in this way. Do you think the organization has selected the most appropriate linkage mechanisms? Why or why...
I have the problem in bold below. I am completely confused. I am hoping that I...
I have the problem in bold below. I am completely confused. I am hoping that I will see how you did this and will be able to follow it. Please remember that I have just started this so please don't use any complex features that an absolute beginner (like me) wouldn't know. Additional information:   /*This is what everyone owes before tax and tip:     Person 1: $10     Person 2: $12     Person 3: $9     Person 4: $8     Person 5: $7     Person 6:...
The question below is very long and I am not sure how to answer some of...
The question below is very long and I am not sure how to answer some of the questions. How much energy is needed for normal breathing? and How might this change with lung disease? how the ingredients in tobacco smoke damage/impair the respiratory system? What brain region controls respiration? What gas do the respiratory centers of the brain detect? How does this affect the respiration rate??
I have a concept question that I am not sure how to answer: ABC Company is...
I have a concept question that I am not sure how to answer: ABC Company is in the process of preparing a budget for the upcoming year. The marketing department has just increased the number of units in the sales budget by a significant 50% as compared to the last sales budget that was prepared for the year. Explain the impact this change will have on the Cash Budget. Be specific about… how the components of the Cash Budget will...
The Table in my homework question below is completely wrong. I am not sure where I...
The Table in my homework question below is completely wrong. I am not sure where I went wrong in my calculations but coud you rework this question and answer the parts below?? Here are earnings per share for two companies by quarter from the first quarter of 2009 through the second quarter of 2012. Forecast earnings per share for the rest of 2012 and 2013. Use exponential smoothing to forecast the third period of 2012, and the time series decomposition...
I am not sure where, to begin with, this problem... "You have found the following historical...
I am not sure where, to begin with, this problem... "You have found the following historical information for DEF Company:                          Year1       Year 2        Year 3        Year 4 Stock Price        $46.29         $49.74          $54.55          $57.07 EPS                  $2.04 $2.9    $2.81    $3.78 Earnings are expected to grow at 8 percent for the next year. Using the company's historical average PE as a benchmark, what is the target stock price in one year?"
I am sure this is a silly question, but I was reading something that described the...
I am sure this is a silly question, but I was reading something that described the pre big-bang universe as having "nearly infinite mass." How can something be "nearly" infinite? The term seems to make no sense.
I am not quite sure what this question is asking, nor do I understand how to...
I am not quite sure what this question is asking, nor do I understand how to apply the lower-of-cost-or-NRV. The controller of Alt Company is applying the lower-of-cost-or-net realizable value basis of valuing its ending inventory. The following information is available: Cost Net Realizable Value Lawnmowers: Self-propelled $14,800 $17,000 Push type 19,000 18,000 Total 33,800 35,000 Snowblowers: Manual 29,800 31,000 Self-start 19,000 21,000 Total 48,800 52,000 Total inventory $82,600 $87,000 Compute the value of the ending inventory by applying the...
I have homework on this but I am not sure how to solve it and which...
I have homework on this but I am not sure how to solve it and which formula to use in excel, can u please help me Rebecca is considering buying a 2019 Genesis G70 costing $37,900 and finds that the retaining values of the vehicle over the next four years are as follows: Percent of the total value retained after 24 months: 71% Percent of the total value retained after 48 months: 53% If her interest rate is 5% compounded...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT