Question: IN PYTHON (without using numpy and use of comments to describe the purpose of your lines of code) def main(): # define the variables needed

IN PYTHON (without using numpy and use of comments to describe the purpose of your lines of code)

IN PYTHON (without using numpy and use of comments to describe the

def main(): # define the variables needed to test the required functions myvals = [-1, 6, 2, -3, 5, 5, 3, -5, 2, 5, 3, 3, 10, 5] mymatrix1 = [[50, 3.7, -7, 4], [-8, 9, 310, -1.8], [-120, 7.9, 3.2, 13]

] mymatrix2 = [[19, 3.7, -7], [-8, 9, -1.8], [7.9, 3.2, -11], [4.3, -0.32, 4] ] p1 = [3, 1, -2, -8] p2 = [2, 1.4, 1, -1, 2] x1 = 2.9 x2 = -3.4

# for part c) poly = polyval(x1, p1) print('part c) Polynomial value for (x1= {:.2f}) = {:.1f}'.format(x1, poly)) poly = polyval(x2, p2) print('part c) Polynomial value for (x2= {:.2f}) = {:.1f}'.format(x2, poly)) print() # print a blank line # for part d) row, col = location_of_largest(mymatrix1) val = mymatrix1[row][col] print('part d) ', val, row, col) row, col = location_of_largest(mymatrix2) val = mymatrix2[row][col] print('part d) ', val, row, col) main()

ANSWERS:

part c) Polynomial value for (x1= 2.90) = -206.0 part c) Polynomial value for (x2= -3.40) = 315.4 part d) 310 1 2 part d) 19 0 0

c) Write a function defined as: def polyval(x, coeffs): x : a float coeffs: an array containing the coefficients of a polynomial, in order from the coefficient of the lowest power to the coefficient of the highest power. return value: the value of the polynomial for the given value of x P(x)=a0+a1x+a2x2+a3x3+a4x4 Note: Use Google to learn how to raise a number to a Power in Python. d) Write a function defined as: def location_of_largest (amatrix): amatrix: a full matrix of floats and integers return value: the location (row and column numbers) of the largest magnitude value (largest absolute value) in amatrix Note: Use Google to learn how to determine the absolute value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!