Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given two equal - sized one - dimensional arrays a and b , calculate the followings: multiply the two arrays element - wise add the

Given two equal-sized one-dimensional arrays a and b, calculate the followings:
multiply the two arrays element-wise
add the first element of a and the last element of b
divid even-indexed elements of a by even-indexed elements of b
Each of the above calculations should become an output value of your function.
Here are some concrete examples of what is expected:
given a =[3,1,1] and b =[8,2,7], the output of the function should be 1)[3*8,1*2,1*7]=[24,2,7]; 2)3+7=10; 3)[1/2]=0.5.
given a =[-1,1,-2,2,-3,3] and b =[0,-1,0,-2,0,-3], the output of the function should be 1)[-1*0,1*-1,-2*0,2*-2,-3*0,3*-3]=[0,-1,0,-4,0,-9]; 2)-1+(-3)=-4; 3)[1/-1,2/-2,3/-3]=[-1,-1,-1].
Note that the grader generates random assessment cases and above example is not the only assessment cases. You should utilize 'Code to Call Your Function' script box and thoroughly test your function with more input arguments before making a submission.
Task
Write a function element_wise_arithmetic that takes two inputs arguments and returns three output values. The input arrays will not be empty and always be equal in the number of elements, so you don't need to worry about that.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

Students also viewed these Databases questions

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago