1 00:00:00,490 --> 00:00:07,600 In this situation, we are discussing Biton metrics, implementation, and despite Permax metrics, 2 00:00:07,600 --> 00:00:11,750 implementation will be demonstrated using some sample code. 3 00:00:12,130 --> 00:00:13,090 We shall run them. 4 00:00:13,120 --> 00:00:14,290 We shall execute them. 5 00:00:14,330 --> 00:00:15,610 We should outputs. 6 00:00:15,790 --> 00:00:19,450 And also from there will be getting the idea how to write the code. 7 00:00:19,690 --> 00:00:21,010 So here is a demonstration. 8 00:00:21,850 --> 00:00:24,850 A matrix is a two dimensional data structure. 9 00:00:24,880 --> 00:00:32,100 In the real world, we often have to define one rectangular data table to support our data. 10 00:00:32,380 --> 00:00:37,330 And obviously in this particular day that will be having multiple number of rows and multiple number 11 00:00:37,330 --> 00:00:37,850 of columns. 12 00:00:38,260 --> 00:00:43,430 So let us discuss in our PyCon how we can define a two dimensional matrix. 13 00:00:43,870 --> 00:00:47,710 So here you see here we are defining a two dimensional matrix here. 14 00:00:48,130 --> 00:00:51,820 We are defining one list at least as having three elements. 15 00:00:51,820 --> 00:00:58,960 And each element individually is another list and consisting of, say, one string and five integer 16 00:00:58,960 --> 00:00:59,320 data. 17 00:00:59,770 --> 00:01:05,590 So this is known as a two dimensional matrix with integers and obviously with some strings here also. 18 00:01:06,010 --> 00:01:07,690 So another nested list. 19 00:01:07,720 --> 00:01:13,750 But it cannot be treated as a matrix because they are having different number of elements in this nested 20 00:01:13,750 --> 00:01:14,240 lists. 21 00:01:14,410 --> 00:01:17,740 Here you can find we are having the six elements that we are having. 22 00:01:17,740 --> 00:01:21,920 Six elements are there, but we are having four elements have got listed here. 23 00:01:22,270 --> 00:01:23,970 So now let us go for the printing. 24 00:01:23,980 --> 00:01:26,650 We can see that how the outputs are coming. 25 00:01:26,650 --> 00:01:31,990 So it is known as a two dimensional matrix with integers and along with the strings. 26 00:01:32,320 --> 00:01:37,180 But the next one is not a matrix here because they are not having the same number of rules and columns. 27 00:01:37,450 --> 00:01:42,030 So each and every data items are having different number of elements inside it. 28 00:01:42,340 --> 00:01:47,910 So here we are having 611 cerebellar about having four elements here with having six elements back again. 29 00:01:48,070 --> 00:01:53,200 So it is not a matrix, it is a list at least, but it can be considered as a matrix. 30 00:01:53,410 --> 00:01:57,310 So having three rows and six columns, we can consider it. 31 00:01:57,790 --> 00:02:02,550 So now let us go on creating one dynamic matrix, using the loop in between here. 32 00:02:02,830 --> 00:02:03,970 So how to create that one. 33 00:02:04,450 --> 00:02:09,270 So N is three, M is equal to four and it is equal to zero. 34 00:02:09,280 --> 00:02:12,160 That is the one single element in this particular list. 35 00:02:12,340 --> 00:02:13,210 Start end. 36 00:02:13,210 --> 00:02:15,460 That means it will be repeated for any number of times. 37 00:02:15,640 --> 00:02:18,010 That means it will be repeated for three number of times. 38 00:02:18,220 --> 00:02:21,590 So if you this we are getting the outcome like this one. 39 00:02:21,910 --> 00:02:26,050 So now for I in range N so end is there having the value three. 40 00:02:26,230 --> 00:02:34,300 So this will be ranging from zero one and two eight is the goal to start in four for each and every 41 00:02:34,450 --> 00:02:35,740 location of this. 42 00:02:35,740 --> 00:02:38,400 I that is the location I ate. 43 00:02:38,410 --> 00:02:41,410 Index will have a zero for any number of times. 44 00:02:41,410 --> 00:02:48,580 So it means the the value for so far as for number of times it will be there for each and every index 45 00:02:48,580 --> 00:02:49,090 of a. 46 00:02:49,180 --> 00:02:55,630 So ultimately if I print then I'm getting a matrix which is having three rows and four columns and all 47 00:02:55,630 --> 00:02:59,130 the members of this list and the nested list are zeroes. 48 00:03:00,010 --> 00:03:02,410 So I know how to access our elements there. 49 00:03:02,430 --> 00:03:04,020 So now let's go for this. 50 00:03:04,360 --> 00:03:09,490 So if we print a zero, that means that zero element will get printed and that is another list. 51 00:03:09,610 --> 00:03:14,400 So this particular outcome will be in if you go for this, a zero one. 52 00:03:14,680 --> 00:03:20,590 So that means we are printing this very element because the zero location is having one list and it's 53 00:03:21,010 --> 00:03:22,030 index number one. 54 00:03:22,030 --> 00:03:24,060 That means this zero will get printed here. 55 00:03:24,400 --> 00:03:26,220 So one comma two. 56 00:03:26,230 --> 00:03:29,110 So that means we're not we are having this eight one two. 57 00:03:29,320 --> 00:03:34,550 That is where having the zero index, there is a one index and two means it is there is a the index 58 00:03:34,550 --> 00:03:37,930 that is at the one index and it is at zero at the index. 59 00:03:37,930 --> 00:03:40,270 So this particular gyro will get printed here. 60 00:03:40,740 --> 00:03:46,240 So also we can go for the negative indexing also we can go for the negative indexing so we can find 61 00:03:46,240 --> 00:03:46,480 here. 62 00:03:46,490 --> 00:03:47,810 So it has got printed. 63 00:03:47,830 --> 00:03:50,140 Now we are going to print this minus one. 64 00:03:50,350 --> 00:03:53,260 So minus one means this particular list will get printed here. 65 00:03:53,650 --> 00:03:55,420 So minus one, minus two. 66 00:03:55,660 --> 00:04:00,600 So from this minus one, we are having this minus two means this very element will get printed here. 67 00:04:00,910 --> 00:04:02,620 So minus two, minus three. 68 00:04:02,770 --> 00:04:06,700 So minus one, this is my minus two and it's minus three means. 69 00:04:06,700 --> 00:04:10,840 This is our minus one, it is my minus two and it is my minus three. 70 00:04:10,840 --> 00:04:13,220 So this particular element has got printed. 71 00:04:13,240 --> 00:04:19,480 So in this way in case of Matrix also we can use that indexing, we can do the slicing accordingly with 72 00:04:19,720 --> 00:04:20,590 using index. 73 00:04:20,770 --> 00:04:24,550 We can we can extract the requested items from this matrix. 74 00:04:25,570 --> 00:04:29,080 So change elements of metrics in baton, so print it. 75 00:04:29,140 --> 00:04:30,430 So we are having this one. 76 00:04:30,430 --> 00:04:33,280 So print date, we're having these respective metrics. 77 00:04:33,520 --> 00:04:35,470 So be is equal to a zero. 78 00:04:35,470 --> 00:04:40,900 That means this will be assigned to B and whenever we are printing B, we are getting these values here 79 00:04:42,250 --> 00:04:43,780 and now we are going for this. 80 00:04:43,780 --> 00:04:48,010 B one is equal to seventy five, so B one is seventy five minutes. 81 00:04:48,280 --> 00:04:50,020 So this very location will have the value. 82 00:04:50,050 --> 00:04:54,460 Seventy five and here you see written B is equal to zero. 83 00:04:54,820 --> 00:04:58,270 That means here the respective values. 84 00:04:58,270 --> 00:04:59,790 That means here we have done the. 85 00:05:00,320 --> 00:05:06,440 The copy of this eight, there is a zero element will be copied to be, so be, and they both will be 86 00:05:06,440 --> 00:05:08,800 referring to the same memory addresses. 87 00:05:09,080 --> 00:05:14,330 So whenever you are printing this value of a I'm finding that that 75 has got updated here. 88 00:05:14,340 --> 00:05:17,050 Also the seventy five has got updated here also. 89 00:05:17,300 --> 00:05:23,120 So to get harder to get a better clarity on this concept, please watch the video on the shallow copy 90 00:05:23,120 --> 00:05:25,210 and the tape copy we have done separately. 91 00:05:25,790 --> 00:05:28,770 So now be one is equal to 75, so print. 92 00:05:29,030 --> 00:05:31,550 So it has got the updated content of the beat. 93 00:05:31,550 --> 00:05:37,340 But if you go for the print, we are finding that that 08 element is having the seventy five has got 94 00:05:37,340 --> 00:05:38,740 updated in this list. 95 00:05:38,750 --> 00:05:41,220 Also, it is equal to this. 96 00:05:42,150 --> 00:05:44,690 That means we are having this zero one two. 97 00:05:44,720 --> 00:05:49,410 So in the second index the list has got updated with this new list content. 98 00:05:49,790 --> 00:05:56,280 So in this way we have shown you that how to do some changes of elements of a matrix in Python. 99 00:05:56,720 --> 00:06:02,900 So in our discussion, we have discussed what is a matrix and how to implement it and how to do operations 100 00:06:02,900 --> 00:06:03,890 on this matrix. 101 00:06:04,310 --> 00:06:05,540 Thanks for watching this video.