Python Program to Add Two Matrices

preview_player
Показать описание
Add two matrices: Adding two user entered matrix using python & Nested loop is an easy task. Adding two matrix and displaying it can be done using python programming easily. In this program we will use for loops to iterate through each row and each column. We will add the corresponding elements in the two matrices and store it in the result.

Best Hindi Videos For Learning Programming:

►C Language Complete Course In Hindi -

►JavaScript Complete Course In Hindi -

►Django Complete Course In Hindi -

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

Kis kis ko GAME DEVELOPMENT in UNITY ka pura Course chahiye


Harry bhai dal do





Like karo taki harry bhai ko comment dikhe 😘😘😘😘😘😘😘😘😘

rishabhbohra
Автор

Thank you very much Harry sir, I learnt the logic and able to perform different operation like subtract/multiplication etc

akshaysuryawanshi
Автор

Really you're doing outstanding And thanks a lot for making such tutorials... They are very helpful... But one suggestion... Plz complete the series first whatever you have started... That will be really beneficial

aishwarya
Автор

thts true hardly anyone likes it ...u know the reason behind it its because we get engaged so deeply in ur videos tht we forget to like i liked ur video only when you said no one likes it or else i would watch the whole video bit not like it ... but im a subscribr of yours

varuntheeditor
Автор

Kar liyaa sir appkee English channel koo subscirbe aur Sir belated Happy Teachers Day

mohitshastri
Автор

Sir Seriously mjhy assignment mila ha yeh, or ma pareshan tha, thank you so much, you are the best <3
Number 1 Youtuber <3

abdullahanis
Автор

And happy teacher's day
You teach me python

Info_teria
Автор

Harry bhai congratulations in advance for getting 600k subscriber family

raghuveersinghlodhi
Автор

Sir please vedio for flutter in python language
Sir Maine aapke sari vedios dekhi hea👍👌👌👌👌thanks for vedios

siddiqajamadar
Автор

Password cracking using python ka tutorial lao please sir

soulking_adi
Автор

Harry bhaei please flutter or dart pay vedio bna do Hindi k sare vedios YouTube k samj nhi ate buss Aap k vedios ascche say smaj ate heai

siddiqajamadar
Автор

Sir koi data science pe video banao na ki kaise kare kya kare

akshayvarat
Автор

Bhai tere channel per Python 🐍 dekhne ke liye tarash gaya me
Aaj Bahut din baad Harry Bhai ne kuchh Python wala post kiya hai.

ayushagrawal
Автор

def greet(name):
return ("Thanks\t"+ name)
code = greet("Harry")
print(code)

cookwithadi
Автор

keep doing what you're doing bro!! big ups!!

TheHamza
Автор

harry sir tell me he use of trignometric formulas and calculations in programming in python and in which type of condition which we need to perform these type of calculations

Anonymous-yges
Автор

I didn't undersand A[i][j] ...what this mean exactly? Can anybody help me?

Prachi
Автор

I have already subscribed your English channel 1 year before 👍👍

ayg
Автор

def matrixAddition(matA, matB, m, n):
outputMat = []
for i in range(0, n):
row = []
for j in range(0, m):
sum = matA[i][j]+matB[i][j]
row.append(sum)
outputMat.append(row)

return outputMat

def displayMatrix(matX, m, n):
for i in range(0, m):
print(matX[i])


def createMatrix(m, n):
outputMat = []
for i in range(0, n):
row = []
for j in range(0, m):
inp = int(input(f"Enter [{i+1}]x[{j+1}] element for the Matrix: "))
row.append(inp)
outputMat.append(row)

return outputMat

if __name__ == "__main__":
m = int(input("Enter the numbers of columns in your matrix: "))
n = int(input("Enter the numbers of rows in your matrix: "))

matA = []
matB = []
matC = []

print(f"Enter all the {m*n} elements of Matrix A down below: \n")
matA = createMatrix(m, n)

print(f"Enter all the {m*n} elements of Matrix B down below: \n")
matB = createMatrix(m, n)
print("\n*** Matrix A *** \n")
displayMatrix(matA, m, n)
print("\n*** Matrix B *** \n")
displayMatrix(matB, m, n)

print("The sum of matrices A & B is: \n")
print("\n*** Matrix C *** \n")
matC = matrixAddition(matA, matB, m, n)
displayMatrix(matC, m, n)



Have tweaked the program a bit, hope that it's easier to understand and the output more appealing to the eyes.

PS: Adding a function to multiply two matrices will take it up another notch.

Love you, Harry Vai!!!

vaibhavyadav
Автор

Bro higher programming ki videos bhi banao plzzz
Pure YouTube par easy or starting point ki programming sikhayi jaati hai

mayankjain