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 (a):

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 b) 12096.0 -616

b) Write a function defined as: def MatrixProductSmallerThan(A, val): A: a FULL matrix (list of lists) containing integers or floats val: a float or integer. return value: the product of the terms in the matrix that are smaller that val. Note: for this function, 2 is larger than 5,3 is larger than 4, etc

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_2

Step: 3

blur-text-image_3

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

What is an RFP, and how does it differ from an RFQ?

Answered: 1 week ago