Question: 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. The 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 3, that element is multiplied by 10. b) If an element of the matrix is a multiple of 6, that element is divided by 10. 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[0]) print(B[1])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
