Learn how to do matrix multiplication in Python using @
operator.
@
operator is supported in Python version 3.5 and above. The operator works on ndarrays
# Matrix multiplication using @
import numpy as np
import random
# Generate a list
X = [[i for i in random.sample(range(0, 10), 3)] for i in range(3)]
Y = [[i for i in random.sample(range(0, 10), 3)] for i in range(3)]
# You can use numpy
X = np.array(X)
Y = np.array(Y)
Z = X @ Y
print(Z)
@vidyasagar Machupalli
Top comments (0)