• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
August 09, 2022 |16.2K Views

Python Program to Multiply Two Matrices

Description
Discussion

In this video, we will write a program to multiply two Matrices in Python.

Below is the list of approaches that we will cover in this section:

1. Multiply the two matrices using the iterative approach.
2. Implementing the code using the NumPy module

In the iterative approach, we will take 3 loops that will handle the multiplication. 
The first loop will run till the length of the A array, the second loop will run until the length of B[0](length of the array in 0 indexes), and the third loop will iterate till the length of the B array. It should be noted that the array which will store the result should be equl to the size of number of rows *number of columns.

Another method is to simply use the NumPy module: It provides np.dot() function which takes array and perform a dot operation on it to give the result.

Python program to multiply two matrices:
https://www.geeksforgeeks.org/python-program-multiply-two-matrices/