Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1) In this question, you will write a Python function to modify the elements of a square matrix. The input to the function should a

image text in transcribed

Q1) In this question, you will write a Python function to modify the elements of a square matrix. 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. A=[133441] 3-Call your function with the following matrix as input. Include the result in your report. A=[13158] 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 ) 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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago