2

Python Program to Multiply Two Matrices

 1 year ago
source link: https://www.geeksforgeeks.org/videos/python-program-to-multiply-two-matrices/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python Program to Multiply Two Matrices

Python Program to Multiply Two Matrices
Hey everyone. Welcome. The Geeks for geeks. In
  • 280 Views
  • 09/08/2022

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, Numpy module provide 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/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK