Run it. And what happened?

So we printed out num one. It was one then we ran this function, and

inside there we said, num twelve. Is eual to two.

Then we said num one is equal to NUM1 + one.

It printed out three, then we printed out NUM1 again.

Hm. A little strange.

Well, let's see, inside the function, it said NUM1 is equal to two.

That seems to be understandable. We changed the value of NUM1 to be two.

Then we said, well, NUM2 is two + one, that's three.

We got a three but it print out, It said num1 is one here,

What happened? We went through, and we said num1 is equal

to two. We created a new local copy of num1. So,

it's not really good to reuse variables like [inaudible].

There's a global num1 here, and there's a local num1. So, I made a second local num1

and actually changed its value to two. When the function finished executing, that

local version, disappeared. And when I asked to print the value of num

one down here, well, the global variable still exists, and so, it printed out a

one. So the critical thing to understand in

here is that if I try to actually go through and even modify a global variable

inside this, in front of here, it's impossible.

I can't do it, at least the way I've done it right here.

So, the critical thing is that anything you create in a side, inside a function is

going to be a local variable. So let's do an example where we construct

a function and use local variables inside it.

So the example that I want to consider, is this problem of converting Fahrenheit to

Kelvin. So let's make a function that does that.

So we're going to do that, and we're going to use two local variables in here.

So let's do it. We'll say define Fahren to Kelvin.

Just going to take the Fahrenheit, as parameter and we're going to create two

local variables. What is going to be, the value if we

converted from Fahrenheit to Celsius? We'll, hang on to that for a second before

we try to convert to kelvin. So, let's see, we can say Celsius is equal

to five-ninths times, let's see, the Fahrenheit minus 32.

And then what do we need to do? We need to go through and add something to

that temperature in Celsius. And what we need to do is add, and we need

to add the, the temperature in kelvins of zero Celsius.

So, let's just make a constant that does that.