Thursday 25 June 2020

Group A Assignment No 3 Python Program for Matrix Operation like Addition, Substraction, Multiplication and Transpose


Problem Statement: 

Write a python program to compute following computation on matrix: 

a) Addition of two matrices 

b) Subtraction of two matrices 

c) Multiplication of two matrices 

d) Transpose of a matrix 

-------------------------------------------------------------------------------

Now, the first question comes to our mind is how to declare a matrix in python ? how to store elements in python ?

Let's see......

Using List as a data structure  in Python,  we can create matrix in Python.

How ?

 

Output of this code is as Follows:

Matrix Creation and Storing value in it from user is as follows...
Enter number of rows in matrix:3
Enter number of cols in matrix:3
Enter the value for mat[0][0]:: 10
Enter the value for mat[0][1]:: 20
Enter the value for mat[0][2]:: 30
----------------------
Enter the value for mat[1][0]:: 40
Enter the value for mat[1][1]:: 50
Enter the value for mat[1][2]:: 60
----------------------
Enter the value for mat[2][0]:: 70
Enter the value for mat[2][1]:: 80
Enter the value for mat[2][2]:: 90
----------------------
The user entered elements in matrix are as follows...
10 20 30
40 50 60
70 80 90
>>>


data structures and algorithms Web Developer

No comments:

Post a Comment