00:02
So in this question we are given that we must ask the user for a 3x4 matrix to be entered.
00:10
And then we define a function which takes the matrix and a single column index and then prints the or returns the sum of that column of the matrix.
00:22
So how we enter the matrix is that we take the matrix row by row.
00:27
We take a row from the user and save it as a row of the matrix, take the second row and then to third row and then we do the operation after that.
00:37
So this part of the program takes the input matrix into a storage into empty variable called mat.
00:49
So what we do, what i have done in here is that i've taken, we are supposed to take a three by four matrix.
00:55
So three rows and four columns.
00:57
So every row should have four values.
01:00
So i first input a message or print a message with the input function that please enter force space separated values and row 0, row 0 1 and 2.
01:15
So what i'm using here is the f string which is in python 3 onwards.
01:21
So basically what we do is that usually this is the portion shown here.
01:29
Is the format that has been used that is used in the printing of values.
01:35
If you want to print a string as well as values within each other in the same go, so you use curly brackets to hold place for a variable value and then you do dot format and give the values in the same order that they came.
01:50
So here this would correspond to the first variable, this would correspond to second variable.
01:54
So the f string actually makes it a bit simpler.
01:57
If you type f before the colon, or sorry, the apostrophe in which the string resides, you can actually put a curly bracket and put the variable within that as you go.
02:12
So this is a new way of writing s string.
02:14
So just to clarify, this is the same as the old format way of writing it.
02:19
So here the r values being passed because as you see on the right side, i'm entering the row number as well into the message.
02:27
So that the user know which row we are talking about.
02:29
So that will be then taken as a string because input function gives a string not an integer number or anything.
02:36
So that string is split using space because i've asked the user to split it with space or at least put space between the two, between the columns.
02:44
So that is split with space and that will give me now a set of numbers which are, let's say a, b, c, which are still characters, but they are now different elements of a string, of a list.
03:00
Then we i initialize a row element or a row variable and in the matrix row that i have input and converted to a list now, i check each element by running a fall loop through that for an in each element, each element in the m row where it is not empty because what can happen sometimes is that you may have one space, two, space, three, space four space.
03:25
If someone gives the space there's another empty element here which will be an empty string which i don't want.
03:29
Or there may be two spaces by mistake somebody has given like that so all those will be taken care of by not taking the empty string to append in my matrix so if it's not empty then i take this empty row matrix or list and append my eval output of that end because eval will convert the string into the digit or the integer or the number and then what i do at the end of this is that i append this row as it is as a list of numbers now a b, c, d, these are numbers and i make it a appendet as a row of the matrix of the empty matrix that i have.
04:07
So like this when i do it three times, i first put one row, then i put another row and then i put the third row and this every every row has, every row has four elements.
04:17
That's how we get my three by four matrix.
04:20
So then what we do is this print statement does nothing so you can just forget about it, no problem.
04:27
Then we define the sum function, the sum column function, which as the problem says must be past the matrix and the index column index.
04:36
So what it does is it simply initializes the zero sum because that's where it will commit the sum of each element of the column...