Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
600 B
7
Indexable
Never
import numpy as np

#Create a 3x3 matrix (matrix_A) using np.arange with values ranging from 1 to 9.
data=np.arange(1,10)
matrix_A=data.reshape(3,3)
print(matrix) #3*3 matrix A

#Generate a 3x3 random matrix (matrix_B) using np.random
matrix_B=np.random.rand(3*3)
print(matrix_B)

#Perform matrix addition: matrix_C = matrix_A + matrix_B.
matrix_C=matrix_A+matrix_B
print("Addition of matrix_A and matrix_B is :",matrix_c)


#Calculate the element-wise product: matrix_D = matrix_A * matrix_B.
matrix_D=matrix_A*matrix_B
print("Product of matrix_A and matrix_B is :",matrix_D)


Leave a Comment