๐Ÿ
B.TECH I YEAR โ€ข II SEMESTER โ€ข R25

Python Programming - Lab Manual

Python Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š II Semester ๐Ÿ Python Programming ๐Ÿงช Lab Program
Selected Program

multiplication of two square matrices

โ† All Python Programs

Aim:

☛   Write a python program to perform multiplication of two square matrices.

Solution :


In this program we use "numpy" package to create matrices. So we need to install "numpy" package using the following commands.

To Install in Windows:

 pip install numpy 

To Install in Linux:

 sudo apt-get install numpy 

PROGRAM: (matrix_mul.py)

 
import numpy as np
a = np.array([[ 1 , 2 ] , [ 4 , 5 ]])
b = np.array([[ 6 , 5 ] , [ 3 , 2 ]])
c = np.dot(a,b)
print(" Multiplication of two Square Matrices is \n " , c)

OUTPUT:

 
Multiplication of two Square Matrices is
  [[12  9]
 [39 30]]


๐Ÿ’ป Run This Python Program

multiplication of two square matrices
The selected Python program is loaded automatically into the editor. Edit the program, provide input if required and click Run.

The compiler is embedded using OneCompiler. Your Python program runs inside the embedded Python environment; Study Glance does not execute Python code directly on your web server.
โ† Back to Python Lab Programs ๐Ÿ“š All Lab Manuals