0% found this document useful (0 votes)
32 views

Pyhton (Matrix Calcu)

The document describes a matrix calculator project created in Python. It allows users to input values for two matrices, select an operation (addition, subtraction, or multiplication) to perform on the matrices, and displays the output. The project uses NumPy to represent matrices as arrays and perform the selected operation. It takes user input for the number of rows and columns in the matrices, validates the input values, and allows correcting mistakes in the matrix values.

Uploaded by

999 plus Gamer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Pyhton (Matrix Calcu)

The document describes a matrix calculator project created in Python. It allows users to input values for two matrices, select an operation (addition, subtraction, or multiplication) to perform on the matrices, and displays the output. The project uses NumPy to represent matrices as arrays and perform the selected operation. It takes user input for the number of rows and columns in the matrices, validates the input values, and allows correcting mistakes in the matrix values.

Uploaded by

999 plus Gamer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

A REPORT SUBMITTED AS A PART OF EXPERIENTIAL LEARNING ON INTRODUCTION TO PYTHON

PROGRAMMING (CSE23202),2023

C. V. Raman Global University, Bhubaneswar,


Odisha, India 2023

Topic -: Matrix Calculator


TEAM MEMBER

Name - MOHIT KUMAR


Name - SHUBHAM KUMAR AGARWAL
Regd. No - 2201020610
Regd. No - 2201020693
Email - [email protected]
Email - [email protected]
Contact no. - 9110916852
Contact no. - 9934796956

Name - Y SHERISHA Name - SACHIN KUMAR SINGH


Regd. No - 22010203340 Regd. No - 2201020611
Email - [email protected] Email - [email protected]
Contact no. - 9749071235 Contact no. - 8227012071

Name - SURABHI NAIK Name - TANUSHREE DHURUA


Regd. No - 2201020337 Regd. No - 2201020339
Email - [email protected] Email - [email protected]
Contact no. - 7894570672 Contact no. - 7991095196

Name - MAYANK RAJ GAUTAM Name - MD RAYYANWALI


Regd. No - 2201020678 Regd. No - 2201020650
Email - [email protected] Email - [email protected]
Contact no. - 9789644698 Contact no. - 8207399603

Name - SATRAJEET SINGH Name - ASHLISHA PANDA


Regd. No - 22010203341 Regd. No - 2201020612
Email - [email protected] Email - [email protected]
Contact no. - 9199690050 Contact no. - 7981707030
Introduction
This Matrix Calculator project In Python is a simple
project developed using Python. The project is for
solving the matrix calculations. So, the user can select
any option they want in the calculations. Hence, the user
can use a matrix calculator from this application. The
project file has a python script (main.py). This is a simple
command-line project which is very easy to understand
and use.

Aim of the project

This simple project is in Python. Talking about the


features of this system, this python application is
developed to calculate matrix form to any operations
and it is also capable of handling some sort of
exceptions. Also, this cmd based project is pretty simple
so that the user won’t get any difficulties while working
on it.
Logic of the code

1. first we will define two matices, matrix 1 and matrix


2,where they will store their values respectively
2. we'll take no, of rows and no. of coloumns as user
input and call the function matrix 1 and matrix 2
3. we will code a re enter your matrix values to give a
chance to user to correct their mistake while
inputting the values and to ease the things we will
ask them in which matrix they want to correct their
mistake
4. Now,we will give operators to the user such as
addition,substraction and multipication and ask the
what they want to operate.
5. Now we will import numpy as o and then we will print
the result matrix

Note:-

While entering the value of matrices user is advice to enter


the value in the following order to get the perfect result:-
a11,a12,a13,...,a21,a22,a23.....til the user inputted no. of
rows and coloumns
Code
Input
def matrix1(a,b):
c=a*b
j=[]
n=[]
print("enter values of matrix-1")
for i in range(0,c):
h=int(input("enter number:-"))
j.append(h)
print("your matrix is:-")
for k in range(0,c,b):
x=j[k:k+b]
n.append(x)
print(x)
return n
def matrix2(a,b):
c=a*b
j=[]
n=[]
print("enter values of matrix-2")
for i in range(0,c):
h=int(input("enter number:-"))
j.append(h)
print("your matrix is:-")
for k in range(0,c,b):
x=j[k:k+b]
n.append(x)
print(x)
return n
print("WELCOME TO THE MATRIX CALCULATOR")
a=int(input("enter no. of rows of both the matrices:-"))
b=int(input("enter no. of coloumns of both the matrices:-"))
m1=matrix1(a,b)
m2=matrix2(a,b)
print("DO YOU WANT TO RE-ENTER ANY MATRIX")
print("1.yes")
print("2.No")
i=int(input("enter the serial no. of your choice from above given option:-")

if i==1:
print("which matrix you want to re-enter")
print("1.MATRIX-1")
print("2.MATRIX-2")
print("3.BOTH")
z=int(input("enter the serial no. of your choice from above given option:-"))
if z==1:
matrix1(a,b)
elif z==2:
matrix2(a,b)
else:
matrix1(a,b)
matrix2(a,b)
import numpy as o
a=o.array(m1)
b=o.array(m2)
print("choose an operation:-")
print("1.ADDITION")
print("2.SUBSTRACTION")
print("3.MULTIPLICATION")
choose=int(input("enter the serial no. of your choice from above given option:-"))
if choose==1:
print(a+b)
elif choose==2:
print(a-b)
elif choose==3:
print(a.dot(b))
else:
print("invalid choice")
Output
WELCOME TO THE MATRIX CALCULATOR
enter no. of rows of both the matrices:-2
enter no. of coloumns of both the matrices:-2
enter values of matrix-1
enter number:-3
enter number:-4
enter number:-4
enter number:-5
your matrix is:-
[3, 4]
[4, 5]
enter values of matrix-2
enter number:-1
enter number:-8
enter number:-9
enter number:-6
your matrix is:-
[1, 8]
[9, 6]
DO YOU WANT TO RE-ENTER ANY MATRIX
1.yes
2.No
enter the serial no. of your choice from above given option:-2
choose an operation:-
1.ADDITION
2.SUBSTRACTION
3.MULTIPLICATION
enter the serial no. of your choice from above given option:-3
[[39 48]
[49 62]]

You might also like