Welcome back, I want to talk to you quickly about something called Matrix.
And The Matrix is a way to describe 2D lists or multidimensional lists.
What do I mean?
Well, I can create a matrix and this is a name that I just made so I can call it whatever I want.
But usually these are called matrix in programming.
And it looks something like this, it's an array.
With another array inside of it.
So let's say, for example.
I have one, two, three here.
And then another array, one or less, two to four.
And then another seven, eight, nine.
What's happening here?
Well, it's a two dimensional array.
We have the main array.
And then we have sub iRace, three arrays, to be exact.
Now, why is this useful?
And by the way, this is two dimensional, but we can have multiple ones.
For example, we can have another array inside of this array.
But why is this important?
These type of mattresses come up a lot in topics like machine learning or image processing.
For example, a computer doesn't really know what a photo of a dog is.
The only thing it understands is zeros and ones.
So a lot of photos, for example, let's say we had a very simple photograph of a giant X, maybe this
letter X.
Well, a computer can understand an image based on pixels on the screen, so maybe we can have zero
one zero.
One zero zero or sorry, one here, zero here and then one, and right now a computer can look at this.
And if this represented, let's say, a tiny little pixel here or maybe a pixel here on my screen,
the computer is going to say, oh, there's a one here.
So that means I should make this green in this corner, then dark here, then green, then dark green,
dark green, dark green.
And a computer is able to draw, let's say, an X, and this is a simple example.
And using matrices, we can do a lot of these heavy calculations.
And that's how computers work underneath the hood when let's say, for example, it's trying to display
something.
But the reason I wanted to talk about this here is when you want to access a multi dimensional list,
well, you would do something like this, let's say matrix.
Access the first item.
And the Matrix, which in this case will be this first array, because it's the first item and then
let's say we want to access the zero, and here are let's change this to five.
Well, how do square brackets again and just do zero one.
So if I go.
One here, and let's print that out.
And I click run.
I get five, so it's accessing the first item in the array, so it's going to look at the first Ottery
grab the first item, which is right here, and then grab the second item in that array.
So zero one, which is five.
And you can keep doing this, if he had multidimensional arrays, you can keep adding, keep adding,
keep adding.
To access that information from an array or list, but remember in Python, we want to use the term
list.
I'll see you in the next one.
Bye bye.