Editor

Matrix Multiply

Advanced · Write the code · from NumPy Linear Algebra: Dot Products, Inverses, and Eigenvalues

From the lesson: NumPy Linear Algebra: Dot Products, Inverses, and Eigenvalues

Linear algebra is the math behind machine learning, computer graphics, physics simulations, and data science. Every time a game rotates a 3D object, a search engine ranks pages, or a neural network makes a prediction, matrix operations are doing the heavy lifting.

Read the lesson

Compute the matrix product of A and B, then print the result and its shape.

A = np.array([[1, 2, 3],
              [4, 5, 6]])
B = np.array([[7, 8],
              [9, 10],
              [11, 12]])
import numpy as np
A = np.array([[1, 2, 3],
[4, 5, 6]])
B = np.array([[7, 8],
[9, 10],
[11, 12]])
# Compute and print the product and its shape

More NumPy Linear Algebra exercises

All Python exercises · 50 practice problems · Data Science & Machine Learning quiz