Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The input to the function should a matrix. Th code should check whether the input matrix is square or not. If it is not square,

image text in transcribed
The input to the function should a matrix. Th code should check whether the input matrix is square or not. If it is not square, the Python function should print "the matrix is not square". If the matrix is square, the Python function should modify the elements of the matrix as follows. a) If an element of the matrix is odd and a multiple of 5 , that element is multiplied by 5 . b) If an element of the matrix is a multiple of 4 , that element is divided by 5 . c) Other elements of the matrix are not modified. d) Use for loops for modifying the elements of the matrix. d) The function should return the modified matrix. 1- Include your code in your report. 2-Call your function with the following matrix as input. Include the result in your report. 3-Call your function with the following matrix as input. Include the result in your report. Hint: You can use the "shape" function from the numpy module to find the size of a matrix. The matrix should be defined using the "array" function. Here is an example: import numpy as np A=np.array([[1,2]],float ) B=A.shape \# The first element of B is the number of rows. Its second element is the number of columns print (B[o]) print(B[1])

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions