[MUSIC] Now we want to talk about local variables. What is a local variable? Well, it's a variable that's created inside of a function. These local variables only exist for the duration of the execution of the particular function call in which they were created. They don't exist outside of the function call, and they are not the same variables when you call the function again. Doesn't quite make sense? Well, let's take a look at how all this works. So let's take a look at a function that converts Fahrenheit to Celsius. There're two different kinds of local variables. The first is the parameters of the function. So you can see here we have a parameter called fahrenheit, that is going to be one type of local variable inside of these function. The other are variables that are created inside the function itself, so you can see offset, multiplier celsius. These variables are completely local to this function as well. And what this effectively means is that when you call this function, there becomes a new variable called farenheit, a new variable called offset multiplier and celsius right. And when the function ends, these variables go away all right. They don't exist any longer, all right. And then the next time you call the function a new set get created, all right. So in general this doesn't sort of affect things, functions work the way that we've shown you so far, okay. I set up the temperature, I called Fahrenheit to Celsius. And let's print out the values, okay. I converted 95 to Celsius, which is 35, all right, and we can see that here. Now inside the function what's going on? Inside the function we have variables called fahrenheit, offset, multiplier, and celsius, and you can see their values right before we return from the function here. Fahrenheit is 95, offset is 32, okay, the multiplier is 0.555, and celsius is 35.0. All right, when we return, okay, those variables all go away. They don't exist anymore, but we still have variables called temperature and converted, which we can print out. All right, notice that converted is the variable that we assigned the result of the function two. We're not using the name celsius which was inside of the function, even though that is what was returned, we return celsius. We're returning the value that celsius was naming, and that value was 35. That value then got assigned to converted,we can now use it as converted outside, but we can't use it as celsius outside. Okay, now that all is straightforward, and is what I've shown you before. But let's look at something a little bit more sort of demonstrative here. Okay, now I'm going to create variables before I call the function, that had the same names as these variables inside the function. So you can see here, I have fahrenheit, offset, multiplier, and celsius, and I have intentionally assigned them all values that are different than what they're going to take on inside the function, all right? I'm going to print those values out before. I'm going to call the function, all right? And then I'm going to print them out afterwards, and you're going to see that they're completely unaffected by this function called even though variables have exactly the same name, are being created and used inside the function. Okay so let's look at this all right. So look at the before and after lines first. Notice they are completely unchanged, 27 to 19 and 77. Look inside the function, the variables with exactly the same names, have completely different values now. Because they were local to the function while the function is executing variables with those names get created that are completely different than the variables with those names outside of the function, all right. They take on their values, the function returns, those values go completely away, we don't have them anymore, they're gone, all right? So when we print them out outside of the function, we're getting the variables that existed outside the function that still exist at the time that we call this print all right, okay. The result is as expected we converted 32 degrees farenheit to celsius we expected 0, we got 0, and that's what new temp needle was assigned to okay. It's important to remember that the parameters of a function and the variables that are created inside a function are local to that function. They only exist during the execution of one particular function call. Every time you call the function, a new set of these local variables get created and used right. And then when the function in it returns, those variables go away. Outside of the function, even if variables are named the same okay, they're actually different variables, right. This can be a little bit confusing at first, but you'll get the hang of it pretty quickly.