Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a single Python program (.py) file that fulfills all of the requirements given below. You will upload that single Python file to the Canvas

Write a single Python program (.py) file that fulfills all of the requirements given below. You will upload that single Python file to the Canvas Homework 1 Assignment Dropbox. You will name that file: Firstname_Lastname_CWID.py, using your actual name and student ID (CWID). The description below requires that you write four different functions that perform four unrelated tasks. All four functions and the function named main(), used to call and test the four functions, must be placed in that single Python file. You will test your functions using the particular numerical values (integers, floats or arrays) given in the main() function below. You must use comments in your functions, to describe the purpose of your lines of code

image text in transcribed

The main function below must be written in the program and used for the variables in part (c):

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 b) ans1 = MatrixProductSmallerThan(mymatrix1, x1) ans2 = MatrixProductSmallerThan(mymatrix2, -2.5) print('part b) ', ans1, ans2) print() # print a blank line main()

THE PRINTED ANSWERS ARE:

part c) Polynomial value for (x1= 2.90) = -206.0 part c) Polynomial value for (x2= -3.40) = 315.4

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

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Eric Redmond ,Jim Wilson

1st Edition

1934356921, 978-1934356920

More Books

Students also viewed these Databases questions

Question

Describe the linkages between HRM and strategy formulation. page 74

Answered: 1 week ago

Question

Identify approaches to improving retention rates.

Answered: 1 week ago