Python Program to Multiply Two Matrices

  Рет қаралды 63,634

CodeWithHarry

CodeWithHarry

Күн бұрын

In this example, we will learn to multiply two matrices using nested loops.
We will derive the matrix multiplication formula and then we will switch to the editor to code this matrix multiplication logic up!
Multiplication of two matrices a and b is defined only if the number of columns in a is equal to the number of rows b
Python Practice Programs: • Python Practice Progra...
►Checkout my English channel here: / programmingwithharry
►Click here to subscribe - / @codewithharry
Best Hindi Videos For Learning Programming:
►Learn Python In One Video - • Python Tutorial In Hin...
►Python Complete Course In Hindi - • Python Tutorials For A...
►C Language Complete Course In Hindi -
• C Language Tutorials I...
►JavaScript Complete Course In Hindi -
• JavaScript Tutorials I...
►Learn JavaScript in One Video - • JavaScript Tutorial
►Learn PHP In One Video - • Learn Php In One Video...
►Django Complete Course In Hindi -
• Python Django Tutorial...
►Machine Learning Using Python - • Machine Learning Tutor...
►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
►Advanced Python Tutorials - • Intermediate/Advanced ...
►Object Oriented Programming In Python - • Object Oriented Progra...
►Python Data Science and Big Data Tutorials - • Python Data Science an...
Follow Me On Social Media
►Website (created using Flask) - www.codewithhar...
►Facebook - / codewithharry
►Instagram - / codewithharry
►Personal Facebook A/c - / geekyharis
Twitter - / haris_is_here

Пікірлер: 105
@CodeWithHarry
@CodeWithHarry 4 жыл бұрын
If you share this playlist, make sure to tag me in your Instagram story. Python Practice Programs: kzbin.info/aero/PLu0W_9lII9agqZuv_XJen_BEHycIh-FmG C Practice Programs Playlist: kzbin.info/aero/PLu0W_9lII9ahSEQv6cHtu8JBXNgK2_QMX Instagram: instagram.com/codewithharry English channel: kzbin.info
@cygnusaerospace9570
@cygnusaerospace9570 4 жыл бұрын
Bhai image recognition in Python bana sekh do with new advance
@sonisinha8912
@sonisinha8912 4 жыл бұрын
Sir please make video series on unity game engine for game development and for game programming.....plz reply
@Movies_and_Masti
@Movies_and_Masti 4 жыл бұрын
Harry bhaiya plz help
@CodeWithAaron
@CodeWithAaron 4 жыл бұрын
Harry bhai aap powerpoint pe itne aache se kaise draw karte ho? Jisko Janna hai vo like karo
@yashpatil5405
@yashpatil5405 4 жыл бұрын
Thank u Harry bhai!!! Abhi mai aapki Java ki series follow kr rha hu aur sath-sath python ki bhi practice ho rhi hai! Someone - Who is the best teacher in the world? Me - Harry bhai! Aap free me itne saare chize de rhe ho!!! Koi soch bhi nahi kr sakta ki free me itna kuchh mil skta hai! Aap mere inspiration ho! Thank u harry bhai! Ab meri hobby coding hai! Bahut maza ata hai aapke saath code krne me aisa lgta hai ki aap mere samne hi baithe ho aur mujhe sikha rhe ho!!! Thank u Harry bhai!
@abdaihannan7147
@abdaihannan7147 4 жыл бұрын
Love you bro... Your python tutorials really helped me and it encouraged me to learn more codings.
@san_era
@san_era 3 жыл бұрын
To generate C C = [[0 for i in range(len(A[0])] for j in range(len(B))]
@ajayansaroj5747
@ajayansaroj5747 3 жыл бұрын
syntax error hai
@prateekyadav7679
@prateekyadav7679 2 жыл бұрын
@@ajayansaroj5747 [[0 for i in range(len(A[0]))] for j in range(len(B))]
@kushagrachaturvedi2144
@kushagrachaturvedi2144 2 жыл бұрын
c = [[0] * m] * k
@ilokebib
@ilokebib 4 жыл бұрын
If Harry hearts ❤️ my comment, my dream to become a successful programmer will be fulfilled😊
@imamsharif6320
@imamsharif6320 2 жыл бұрын
Heart nehi mila
@Truth-seeker333
@Truth-seeker333 Жыл бұрын
@@imamsharif6320 😂😂😂😂😂
@BHARATMEENA-o8e
@BHARATMEENA-o8e 5 ай бұрын
A = [[3,2,1], [5,2,0], [1,0,4]] B = [[0,2,5,2], [2,0,1,1], [0,3,4,0]] # A(3x3) B(3x4) --> C(3x4) C = [[0 for x in range(len(B[0]))] for y in range(len(A))] print(C) for row in C: print(row) for i in range(0,len(A)): for j in range(0,len(B[0])): for k in range(0,len(B)): C[i][j] += A[i][k]*B[k][j] for row in C: print(row)
@sonisinha8912
@sonisinha8912 4 жыл бұрын
Sir please make video series on unity game engine for game development and for game programming.....plz reply
@mohitsharma99
@mohitsharma99 4 жыл бұрын
I I am begginer And you motivated for programming
@NarendraSharmaa
@NarendraSharmaa 2 жыл бұрын
Very Precise and too the point video thanks and keep making more and more video's
@shrikantshekhar9982
@shrikantshekhar9982 Жыл бұрын
program to check if you can perform matrix multiplication on 2 matrices A = [[1,2,3],[4,5,6],[7,8,9]] row1 = 0 for i in A: row1 = row1 + 1 column = len(i) print("A",i) print("Row1--",row1) print("Column1--",column) B = [[9,8],[7,6],[3,2]] row2 = 0 for j in B: row2 = row2 +1 column2 = len(j) print("A",j) print("Row2--",row2) print("Column1--",column2) if column == row2: print("Multiplication possible") else: print("Multiplication not possible")
@abhishekgurav5878
@abhishekgurav5878 3 жыл бұрын
U R BEST TEACHER
@irfanhassan5775
@irfanhassan5775 4 жыл бұрын
c=np.zeros(len(a),len(b[0]))
@shivanshgoyal310
@shivanshgoyal310 4 жыл бұрын
Its your 5th video today... I don't believe this!! 🔥🔥🔥
@sandippankhaniya489
@sandippankhaniya489 4 жыл бұрын
Great video harry sir...sir muje kuch problems hai please help it in coding
@aashishmalhotra
@aashishmalhotra 2 жыл бұрын
We can make C = numpy.zeros( [ len(A) , len(b) ] , int)
@rohitchitte5614
@rohitchitte5614 3 жыл бұрын
thank you harry bhai this solution helped me a lot !.
@marthusthang4291
@marthusthang4291 3 жыл бұрын
thanks a lot for explaining in such details.
@aashishmalhotra
@aashishmalhotra 2 жыл бұрын
Thanks bhai problem thi ismae and i will practice python playlist.
@brightside1574
@brightside1574 2 жыл бұрын
Hello, can we do like this x1 = array(range(0,9)).reshape(3,3) print(x1) x2 = array(range(1,10)).reshape(3,3) print(x2) y=x1.dot(x2) print(y)
@harshvardhan7762
@harshvardhan7762 3 жыл бұрын
import numpy as np print("Enter the no. of rows and columns of matrix A with comma separated:") a = input("Enter here: ").split(",") r1 = int(a[0]) c1 = int(a[1]) A = [] print("Enter the no. of rows and columns of matrix B with comma separated:") b = input("Enter here: ").split(",") r2 = int(b[0]) c2 = int(b[1]) B = [] if c1 == r2: for i in range(c1): A1 = [] for j in range(r1): n1 = int(input(f"Enter the value of matrix {i}x{j} is ")) A1.append(n1) A.append(A1) for i in range(c2): B1 = [] for j in range(r2): n2 = int(input(f"Enter the value of matrix {i}x{j} is ")) B1.append(n2) B.append(B1) C = np.zeros([r1,c2],dtype=int) for i in range(c2): for j in range(r1): for k in range(c1): C[i][j] += A[i][k]*B[k][j] print(C) else: print("The condition doesn't satisfied....TRY AGAIN")
@madhukardarade4133
@madhukardarade4133 4 жыл бұрын
Awesome video Harry bhai !!
@aryadas2422
@aryadas2422 2 жыл бұрын
thanks
@tehseenjahan7384
@tehseenjahan7384 3 жыл бұрын
Sir please make a program of taking matrix input from user and then how to multiply them.
@068_gauravchakraborty
@068_gauravchakraborty 2 жыл бұрын
# Function to form a matrix def matrix(m,n): o=[] for i in range(m): row=[] for j in range (n): inp=int(input("Enter the number:")) row.append(inp) o.append(row) print(*o,sep=" ") # to print the matrices in the right format print(" ") return o m=int(input("Enter the number of rows--MATRIX A:")) n=int(input("Enter the number of columns--- MATRIX A:")) m1=int(input("Enter the number of rows---MATRIX B:")) n1=int(input("Enter the number of columns --- MATRIX B:")) print("Please enter the values of Matrix A") A=matrix(m,n) print("Please enter the values of Matrix B") B=matrix(m1,n1) print("Please enter the values of Matrix C as 0 ") C=matrix(n,n1) # taking number of rows from A and Number of columns from B # Function to multiply the matrices def multiply(a,b,c): for i in range(0,len(C)): for j in range(0,len(C[0])): for k in range(0,len(B)): C[i][j]+=A[i][k]* B[k][j] print(*C,sep=" ") return C multiply(A,B,C)
@awmdanger9677
@awmdanger9677 2 жыл бұрын
Adding two matrixes me hai. Harry bhai ki hi video hai. Dekh lo Jake.
@aimunazhar3330
@aimunazhar3330 3 жыл бұрын
Helpful Tutorial!!!
@nehalingole1754
@nehalingole1754 4 жыл бұрын
Thanks for giving us awesome video
@sneharajaparmarparmar
@sneharajaparmarparmar 11 ай бұрын
Kuch samjh nahi aaya
@Satyaprakash__1929
@Satyaprakash__1929 Жыл бұрын
Multiply any matrix def zeromatrix(m,n): output = [] for rowi in range(m): row = [] for coloumnj in range(n): row.append(int(0)) output.append(row) return output def matrixmultiply(A,B): x = len(A) y = len(A[0]) z = len(B[0]) # (x*y) X (y*z) doing output = zeromatrix(x,z) # appending into zeromatrix to get output matrux for i in range(x): for j in range(y): for k in range(z): # got all possible combinations of i j k # for using the following formula output[i][j] += A[i][k] * B[k][j] # += (add) karna hai not =(assign) #Summation of resp elements multiplication kiya return output # taking following matix as example A = [[1,2], [3,4]] B = [[4,3], [2,1]] print(matrixmultiply(A,B))
@kshitijbhandari3219
@kshitijbhandari3219 2 жыл бұрын
if len(a[0])==len(b): print("matrix multiplication is possible") c=[[0]*len(b[0])]*len(a) print(c)
@garvitkohli9142
@garvitkohli9142 3 жыл бұрын
Thank you bhai
@hrishiraj1761
@hrishiraj1761 4 жыл бұрын
Nice Video👍👍👍
@satyajitdas2780
@satyajitdas2780 4 жыл бұрын
Thanks, Harry Bhai. Maja agaya! Praji aise hi logical wale questions. chahiye tha! apka infix to prefix ka bhi gajab tha!
@armanahmed4806
@armanahmed4806 4 жыл бұрын
Nice video harry bhai please make how to count a duplicate program in a list
@TechWithRushabh
@TechWithRushabh 4 жыл бұрын
Great Video Harry Bhai
@ChSajjan
@ChSajjan 4 жыл бұрын
Luv you sir my suggestion for next series after dsa and java is flutter, dart
@prashunraj4578
@prashunraj4578 2 жыл бұрын
Bhaiya recently I saw your video on matrix multiplication using python program and I really liked it and in the video itself you asked us that if anyone can generate the list containing the required no of zeroes with certain rows and certain column for storing the multiplied value in it .So I tried to write the code and i was successful in creating the desired list but I don't know why I am getting the wrong answer of the matrix multiplication.Bhaiya can you please help me in identifying where is the error in the code.I have Been trying this for 5 days but till now I am not able to find it The code is the following:- p=eval(input("enter the value of your 1st matrix"))#in the form of list q=eval(input("enter the value of your 2nd matrix")) r=len(p) s=len(q) t=len(p[0]) u=len(q[0]) x=[] count=1 while count
@068_gauravchakraborty
@068_gauravchakraborty 2 жыл бұрын
MULTIPLICATION OF MATRICES BY TAKING INPUTS FROM THE USER # Function to form a matrix def matrix(m,n): o=[] for i in range(m): row=[] for j in range (n): inp=int(input("Enter the number:")) row.append(inp) o.append(row) print(*o,sep=" ") # to print the matrices in the right format print(" ") return o m=int(input("Enter the number of rows--MATRIX A:")) n=int(input("Enter the number of columns--- MATRIX A:")) m1=int(input("Enter the number of rows---MATRIX B:")) n1=int(input("Enter the number of columns --- MATRIX B:")) print("Please enter the values of Matrix A") A=matrix(m,n) print("Please enter the values of Matrix B") B=matrix(m1,n1) print("Please enter the values of Matrix C as 0 ") C=matrix(n,n1) # taking number of rows from A and Number of columns from B # Function to multiply the matrices def multiply(a,b,c): for i in range(0,len(C)): for j in range(0,len(C[0])): for k in range(0,len(B)): C[i][j]+=A[i][k]* B[k][j] print(*C,sep=" ") return C multiply(A,B,C)
@lishapal8170
@lishapal8170 Жыл бұрын
Thank you
@thejusa1766
@thejusa1766 3 жыл бұрын
automation of resultant C Em = list() if len(A[0]) == len(B): for i in range(len(A)): Em += [[0] * len(B[0]) ] print(Em) else: print("not posible")
@ujjwalandtanmay7917
@ujjwalandtanmay7917 4 жыл бұрын
sir aapki videos amazing hoti hai but main chahata hoon ki aap ek app ko code karein by using python (Pure python)
@bunnyrajender5124
@bunnyrajender5124 2 жыл бұрын
I have a python code for matrix multiplication In that code any two Matrices are multiplied We have to give the mattices two as input and get the result of matrix multiplication
@sairsc8043
@sairsc8043 4 жыл бұрын
I'm 12th grade and I don't know anything I got ur video notification and got some hope
@amitverma7427
@amitverma7427 4 жыл бұрын
Really going to do this
@pallavsahu5536
@pallavsahu5536 4 жыл бұрын
Bro... Can you make a series video on how to create wordpress plugins
@RealmsOfDocumentary
@RealmsOfDocumentary Жыл бұрын
Harry bhai knsa font use krte ho Agr ksi or ko pta h to kindly btade
@koushikextras1013
@koushikextras1013 4 жыл бұрын
Most awaited
@UmerKhan-ro3dy
@UmerKhan-ro3dy 3 жыл бұрын
Harry bhai bnado wo wali video k kisi bhi matrix ko wo multiply krde ya btade k esa nai hoskta wala code please
@shivanshutyagi83
@shivanshutyagi83 4 жыл бұрын
Harry bhai 👋👋
@RohanDasRD
@RohanDasRD 4 жыл бұрын
Bhai Bhai Bhai Bhai Ek din mein 4 Video!
@CodeWithHarry
@CodeWithHarry 4 жыл бұрын
5th hai bhai ye subah se!
@RohanDasRD
@RohanDasRD 4 жыл бұрын
@@CodeWithHarry yes 5th🙈
@bikashborah6853
@bikashborah6853 4 жыл бұрын
Sir data structures and algorithms please
@centralmotivation5256
@centralmotivation5256 4 жыл бұрын
sir aap ne jo video me jarvis banaya tha vo kam nahi kar raha hai. please tell me
@mohsinqureshi6850
@mohsinqureshi6850 4 жыл бұрын
please tell me the code for automated matrix C ? Anyone?
@AdityaSharma-ug6cp
@AdityaSharma-ug6cp 3 жыл бұрын
sir kya ap any matrix ka multipication bana sakte hai mujhe doubt ho rha hai multipication mai programm kam nhi kar rhe hai
@kshitijpatil4590
@kshitijpatil4590 4 жыл бұрын
Harry bhai🤗
@Prajwal985
@Prajwal985 3 жыл бұрын
import numpy as np r_a = int(input("Enter the row for the first matrix : ")) c_a = int(input("Enter the column for the matrix : ")) r_b = int(input("Enter the row for the second matrix : ")) c_b = int(input("Enter the column for the second matrix : ")) if (c_a != r_b): print("Martix multiplication is not possible!") else: C = np.zeros([r_a,c_b],dtype = int) A = [] print("Enter the elements in the matrix A : ") for i in range(r_a): a = [] for j in range(c_a): a.append(int(input())) A.append(a) B = [] print("Enter the elements in the matrix B : ") for i in range(r_b): b = [] for j in range(c_b): b.append(int(input())) B.append(b) for i in range(0,len(C)): for j in range(0,len(C[0])): for k in range(0,len(B)): C[i][j] += A[i][k] * B[k][j] for row in C: print(row)
@rishijha8892
@rishijha8892 4 жыл бұрын
i have an idea make a complex vector space and then do operation
@vaibhavkher6264
@vaibhavkher6264 4 жыл бұрын
What is len C[0]?
@kaharabo6185
@kaharabo6185 3 жыл бұрын
Two matrices in your video's title, but in your example of codes 3 matrice you gave?
@kaustubhdada5764
@kaustubhdada5764 4 жыл бұрын
TOO COOL BHAI
@kshitijpatil4590
@kshitijpatil4590 4 жыл бұрын
Ha bhai banado
@hassankhan3700
@hassankhan3700 3 жыл бұрын
how can i add two matrices with while loop
@shubhamchitre4702
@shubhamchitre4702 3 жыл бұрын
good tutorial but too many ads!
@shridumanish3506
@shridumanish3506 4 жыл бұрын
Ek doubt tha ki agar Vector multiplication na aata ho to, abhi tak to sirf physics me vector aaya hai 😂😂
@kusumaglawe5455
@kusumaglawe5455 4 жыл бұрын
Nice
@namanpratapsingh3558
@namanpratapsingh3558 3 жыл бұрын
Harry bhai banado video
@aryan7069_
@aryan7069_ 4 жыл бұрын
Program bhejduga ... kaha bheju? Aapki email?
@technoman9926
@technoman9926 4 жыл бұрын
Please give me heart harry bhai
@wizhdan
@wizhdan 3 жыл бұрын
Wish there were english subtitle, I cant understand a thing
@ikshadubey5220
@ikshadubey5220 3 жыл бұрын
i didn't understand "len" can you help?
@rohitpatel2937
@rohitpatel2937 4 жыл бұрын
Hi sir, I want help please please sir help me. I want devloped on project but mujhe idea nhi mile rha plz make one video on this topic COLLEGE FEST ONLINE REGISTRATION SYSTEM.
@anonymous-tt2lm
@anonymous-tt2lm 3 жыл бұрын
🤟✌👍
@NarendraSharmaa
@NarendraSharmaa 2 жыл бұрын
I am your Channel Subscriber now , will advise my friends to join as well .
@er.sanaullah
@er.sanaullah 4 жыл бұрын
Sir PC build-up pe video bna do please
@fundamovies
@fundamovies 4 жыл бұрын
Gaming chahiye bro
@fundamovies
@fundamovies 4 жыл бұрын
Agar coding ke liye chahiye to bolo
@er.sanaullah
@er.sanaullah 4 жыл бұрын
@@fundamovies coding ke liye chahiye
@fundamovies
@fundamovies 4 жыл бұрын
@@er.sanaullah ok to AMD ryzen 5 3600 in cpu koi budget gpu lga lena koi budget wala meri suggestion hai gtx 1050 ti tumhare liye kafi hoga 256 gb ki ssd laga lo aur 1 tb ki hdd for storage cabinet your choice ram 8 gb is more than enough or sabse important motherboard me asus a320 lga lo budget me ban jayega pura
@er.sanaullah
@er.sanaullah 4 жыл бұрын
@@fundamovies are bhai mujhe janna hai pc kaise banta hai
@hrishiraj1761
@hrishiraj1761 4 жыл бұрын
Bhai why you ignore my comments Please tell me
@quickymein
@quickymein 4 жыл бұрын
❤️
@KrishnaSahu-vy9rb
@KrishnaSahu-vy9rb 10 ай бұрын
😅😅
@dhanrajsah2451
@dhanrajsah2451 4 жыл бұрын
6th comment
@jeegrandmaster
@jeegrandmaster 4 жыл бұрын
Op
@Demoneyes031
@Demoneyes031 4 жыл бұрын
third comment
@ehteshamahmad220
@ehteshamahmad220 3 жыл бұрын
so much ad this is disgusting
Python Program to Add Two Matrices
17:09
CodeWithHarry
Рет қаралды 64 М.
Python Program #35 - Multiply Two Matrix in Python
8:01
Programming For Beginners
Рет қаралды 34 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
When Rosé has a fake Fun Bot music box 😁
00:23
BigSchool
Рет қаралды 6 МЛН
Multiplication of Matrix Using Numpy - Python Tutorial
7:22
DataMites
Рет қаралды 13 М.
C_60 C program for Matrix Multiplication part 1 | C Language Tutorials
12:21
Jenny's Lectures CS IT
Рет қаралды 213 М.
5 Effective Tips to learn Python fast!
15:57
CodeWithHarry
Рет қаралды 1 МЛН
How to use AI Effectively - Prompts, Tips & Tricks🔥
14:30
CodeWithHarry
Рет қаралды 69 М.
Python Program: How to Multiply Two Matrices?
12:59
WsCube Tech
Рет қаралды 16 М.
Python Program For Matrix Multiplication
19:10
Amulya's Academy
Рет қаралды 80 М.
you need to learn Python RIGHT NOW!! // EP 1
17:42
NetworkChuck
Рет қаралды 2,5 МЛН
Python Program to Check Armstrong Number
18:08
CodeWithHarry
Рет қаралды 102 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН