Instructor: Welcome back.
I wanna talk to you quickly about something called matrix.
And a 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 1, 2, 3 here, and then another array,
1, or let's do 2, 4, 6, and then another array, 7, 8, 9.
What's happening here?
Well, it's a two dimensional array.
We have the main array
and then we have sub arrays, 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 matrices 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 0, 1, 0, 1, 0, 0, or sorry, 1 here,
0 here, and then 1.
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's going to say, "Oh, there's a 1 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 multidimensional list,
well, you would do something like this.
Let's say matrix access the first item in the matrix,
which in this case will be this first array
because it's the first item,
and then let's say we wanna access the 0 in here,
or let's change this to 5.
Well, I'll do square brackets again and just do 0, 1.
So if I go 1 here, and let's print that out,
and I click run, I get 5.
So it's accessing the first item in the array.
So it's going to look at the first outer array,
grab the first item, which is right here,
and then grab the second item in that array.
So 0, 1, which is 5.
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 wanna use the term list.
I'll see you in the next one. Bye-bye.