Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started