Python Program #35 - Multiply Two Matrix in Python
ฝัง
- เผยแพร่เมื่อ 26 พ.ค. 2023
- Python Program #35 - Multiply Two Matrix in Python
In this video by Programming for beginners we will see Python Program to Multiply Two Matrix in Python for beginners series.
Python programming language and program is very easy to learn for students and professionals.
Multiplication of two matrix X and Y is defined only if the number of columns in X is equal to the number of rows Y.
If X is a n x m matrix and Y is a m x l matrix then, XY is defined and has the dimension n x l (but YX is not defined).
==========
Python Programs for Beginners Playlist:
• Python Programs
Python Tutorial for Beginners Playlist:
• Python Tutorial
Java Tutorial for Beginners Playlist:
• Java Tutorial
All Java Programs Playlist:
• Java Programs
Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general-purpose language, meaning it can be used to create a variety of different programs and isn't specialized for any specific problems.
It is very important for students and professionals to learn python programming language that will help you to achieve many tasks easily and to build softwares.
TH-cam Gears:
Microphone: amzn.to/3iIk5K3
Mouse: amzn.to/35irmNF
Laptop: amzn.to/3iG0jyD
#PythonTutorial #PythonProgram #PythonForBeginners #Programming #PythonTutorialForBeginners
============================
LIKE | SHARE | COMMENT | SUBSCRIBE
Thanks for watching :)
same as chat gbt
good job
Thanks 👍
Thank you bro u helped me a lot 😅
Happy to help. Please subscribe and share with your friends :)
thank you soooo much
You're welcome!
Nice explanation bro thnks a ton
welcome
thank you
You're welcome
Thanks
Welcome
Is it normal that I couldn't solve it at all? I found it very difficult.. by the way thanks a lot , you've really helped me..
thanks
Nice❤
Thanks 👍
if we want to input data of matrix from user so how it is done please reply
you can use the input function
watch this video:
th-cam.com/video/sjA5O6Xoetc/w-d-xo.html
i tried this myself and i came across a problem i don’t understand, is says name error: name ‘result’ is not defined, what does that mean 😅
You missed to define result
You are printing result without defining it
1stly define it.
Dude, just a tip. I am not an native english speaker, so if you could talk just a little bit slower, it would be great.
Yes sure.. will improve.. thanks for your suggestion
For now you can decrease the video speed and watch
still cant do it 😥
This is the python code:
from numpy import
m1= matrix("1 2 3;4 5 6;7 8 9")
m2 = matrix("11,12,13;14,15,16;17,18,19")
#multiplication
#only possible when the num of rows in m2 is equal to num of column in m3
'''
It looks like this
m1 = [1 2 3
4 5 6
7 8 9]
m2 = [[11 12 13
14 15 16
17 18 19]]
elements of m1 row1 will multiply to the elemts of m2 columnn1 and the sum will be the first element of the output
m2 row 1 = 1 2 3
m3 column 1 = 11 14 17
cal = 1*11+2*14+3*17=90 (1st row 1st element)
m2 row 1 = 1 2 3
m3 column 2 = 12 15 18
cal = 1*12+2*15+3*18=96 (1st row 2nd element)
m2 row 1 = 1 2 3
m3 column 3 = 13 16 19
cal = 1*13+2*16+3*19=102 (1st row 3rd element)
m2 row 2 = 4 5 6
m3 column 1 = 11 14 17
cal = 4*11+3*14+6*17=216 (2nd row 1st element)
m2 row 2 = 4 5 6
m3 column 2 = 12 15 18
cal = 4*12+5*15+6*18=231 (2nd row 2nd element)
m2 row 2 = 4 5 6
m3 column 3 = 13 16 19
cal = 4*13+5*16+6*19=246 (2nd row 3rd column)
m2 row 3 = 7 8 9
m3 column 1 = 11 14 17
cal = 7*11+8*14+9*17=342 (3rd row first element)
#try applying the logic for and do it for row 3 element 2 and 3
output = [[ 90 96 102]
[216 231 246]
[342 366 390]]
'''
mmul = m2 * m3
print (mmul)
Hope u understand... At first even I couldn't get the logic
please pause video and practice 2-3 times to understand properly
I am getting index out of range error with the same code.
Please check your indices
i tried this myself and i came across a problem i don’t understand, is says name error: name ‘result’ is not defined, what does that mean 😅
did u make the third matrice called result?
(as shown in the video)