0:00
Hello.
00:02
For this problem, you're being asked to write a function that will multiply two matrices and then write a program that will test a user, sorry, test that function by prompting a user to enter two matrices and displaying the product of those two matrices.
00:25
So i'm going to be writing my code in jupiter notebooks and i'm just going to talk through what i have written here.
00:32
So i've started by labeling this programming exercise 11 .6.
00:37
And i defined two functions here.
00:41
The first is multiply matrix that takes input matrices a and b.
00:47
And before i get too much further, i do want to just state that there are multiple ways of writing this.
00:54
This is just what made the most sense.
00:57
To me, but you might prefer to write it in a different way.
01:02
But we're going to take input matrix a and b.
01:07
And in the problem, we're specifically dealing with three by three matrices.
01:17
So i've written this program to only accept three by three matrices.
01:22
It's going to throw an error if it's a matrix of a different size.
01:27
You could actually make it more generic so that it could work for any matrix, any size matrices, as long as the dimensions work so that you can actually multiply those two matrices.
01:44
But i'm just going to work with three by three.
01:46
So we need to initialize a matrix c that's going to hold the product of a and b.
01:52
And i just initialized that with zero.
01:54
So this is a three by three matrix because those were the dimensions given in the problem.
02:03
And then now i'm going to multiply.
02:05
So in order to do that, i want to identify a row and column.
02:10
So we're going to be at a specific location of c.
02:13
And then we want to set that element equal to what it should be equal to based off of the example given in the in the textbook, sorry.
02:30
So for matrix c at location row column, a row zero times b zero column, plus a row one times b one column, plus a row two times b two column is going to be the result that should be at that location.
02:53
And then this function is just going to return that matrix c.
02:58
I wrote a second function to have a user input a matrix.
03:08
I found that that was just going to be easier than having to write all of this out twice.
03:14
So i've defined a function called inter matrix of n.
03:19
It's going to start by printing inter matrix n.
03:23
So it'll say inter matrix 1, inter matrix 2, intermatrix 2, in.
03:30
Then we are again initializing an empty list here.
03:35
So grid is equal to zero...