Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
507 B
4
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
matrix_C


#Calculate the element-wise product: matrix_D = matrix_A * matrix_B.
matrix_D=matrix_A*matrix_B
matrix_D


Leave a Comment