 Good morning evening and everything in between as you can see what we're going to be talking about today is this idea of starting to look into some of the different applications of Python and some of the libraries that we can use inside of Python and so yeah You know the message we're seeing here is numeric and scientific computing, but this is one of the very strongest points to Python and why a lot of say for example data scientists and people use Python so the idea is what we're going to be talking about to at least start is this idea of NumPy, so NumPy numerical Python it allows us to do a wide variety of different types of Applications or Calculations their sword tons of different calculations, especially when we're thinking about things from an array perspective, so An array is sort of like a list and we'll kind of see that So as you can see very simple ways of importing it like before we can import it It's called NumPy the Traditional just as the go-to most people you'll see will do some form of like a as in P for this and again If you've followed along with some of the other lectures that this is just our way of renaming what the library Is going to be called instead of it being NumPy We can kind of chop off a few little words here or letters here and there to make it say now I'm only going to be working with NumPy, so let's go ahead and take a look at some of the different applications that we can work off of So again, I'll come in NumPy as in P now when we think about What we're looking at if I only focused on a list just to show what a list Operation looks like it's nothing terribly crazy Boom, you know, we've got the square brackets. There's some things that we can do with a list I can append to a list I can tweak a list However, when we think about NumPy and how it handles Lists or collections it handles them through something known as an array So the entire idea is what we would do with our traditional list is instead in P. Array This is our way of saying hey, I'm using NumPy's array function Or I'm using I'm accessing the array function from my NumPy and then as you can see it's sort of asking for it It's asking for an object here, but realistically it's saying I need something to store in here So in our case we can come in and we can store Pretty much a list if I came in now and just did a print on this It will look very similar to how we've seen our Our lists in the past one difference, you know, yeah, they're not putting any commas in there That's not really changing it overall of that much and you're still able to access the elements the same way so I can go in and say oh, I want the Element at the second index. That's fine where we start to get into some of NumPy's Strengths is when we start to work on what are known as element wise and array wise Operations so the same kind of thing. Let me say instead of doing just a print of X For whatever reason, maybe I want to double each one of the elements now There are a number of ways we could do this say for example if Again, I had let's see there if I had just done this as a List right and I wanted to double all of those elements I'd have to go in and say for I in range Len X X at I Equals X at I times 2 I could do this print X and That'll do it. No problem. And now again, it's making a list not array. Whatever when we think about NumPy, however When we think about this idea of an element wise operation What we're talking about is for my array for all the contents in my array I'm gonna go ahead and do this operation for each one of those operations of each one of those elements So if I for example came in here now all I'm doing is saying X times 2 What you see in my print statement now is it's going ahead and doing that Across each element and the same thing can come in if say for example, I Wanted to have two arrays that I was working. Oh, I had two arrays. I was working off of an X and a Y Let's say that's a 10 There we are a 10 20 a 30 and a 40 I Can also do the same thing where as instead of saying oh multiply each element by 2 now for each element for each element in this list Added or in this array add the Corresponding element in the same spot So in our case this one and this 10 will get added together this 2 in this 20 We'll get added together the 3 in the 30, you know, what's going on here and just to see that There you go. So let's just see what happens if one of these happens to have an Unstructured or I guess more than one element than the other So my X array has five elements in it and my Y array has four elements in it I save I run and Now it's gonna freak out. This is One of the things about You know when we're trying to do these element-wise operations, you know, it's complaining Hey, you can't quite do that because what it's calling the shape of my array is Not the same as the shape of the other array in this case The message is saying, you know, it's freaking out and saying we can't do that versus an L a a an array that has One dimension with five elements versus a an array with one dimension and four elements I can't quite do that now Specifically you might notice, you know with this it's presenting this as a tuple if you think about it a five comma with some parentheses, it's kind of tuple-esque and the reason why is because if we think about arrays well arrays can be expanded They don't have to just be one dimensional. So say for example, I came in two three Now my x array is not just five elements, but it's 15 elements and not just a list of 15 elements But one it is effectively a matrix. We've gotten it to build a matrix It just doesn't use matrix term for this and just the same kind of way if I came in with my y Did the same thing? All right. Well, let me actually get rid of those fives just to show it off again Same kind of thing element wise operations mean that every element at the corresponding Location again same row same column is going to be in our case added to the same Corresponding element in our other array. So again, this one will be added to this 10 This three will be added to this 30. We hit play We get exactly that same kind of thing also again if I added those fives back just to explore this We should get the same error that we saw before this Five and four. However, instead of it being five comma nothing what we should see is Explaining oh, hey, now you're you know your three by five Array is not matching your three by four