So I put rad in parentheses to say,
look this function has to take one argument, which I will call rad.
Then inside it, I just say print 3.14,
which is approximately pi times rad times rad.
My simple version, that's pi rad squared r squared.
And so when I run that, when I want to execute that.
I call the function circle_area, I pass it 2 as an argument.
That's the radius I want.
I put 2 inside the parenthesis and then it computes it and prints out the results.
So that's how you pass arguments to functions.
So you have to define it in the definition, you name the argument.
And then at run time that two, when you call circle area capacity two,
that two will be bound to rad.
That variable red and so two will be rad.
So it will print out 3.14 times 2 times 2,
it will substitute the 2 in for the rad.
Now functions in addition to taking input values,
they can also return output values.
Those are called return values.
So function can return values if you use a return instruction at the end of
the function.
And notice on my last program, I didn't use return I said, print,
which just prints it to the screen.
That's different than returning a value.
Returning a value, when you return a value,
the whole function call is substituted for whatever the return value is inside
whatever expression you use the function call.
So if you use the function call inside a bigger expression.
So if I say, x plus 5 plus circle_area and I call it with a 2,
then it'll compute with the circle areas with a two.
If I return that, it'll substitute that in.
So, it'll do 5 plus whatever the return value is.
So, I'll give you an example.
So I got my circle_area, I define it.
And this time, I say, return.
Return 3.14 * rad * rad.
Now I say circle_area (2).
If I just call circle_area (2), it returns 12.56.
But if I say, a 3 plus circle_area (2), it return 15.56,
because it just takes a whatever circle_area (2) returns and
it substitute the grade in there into a bigger expression.
3 plus circle_area (2).
So 3 plus 12.56 and the return is 15.56.
So that's a return value and that's useful a lot of times.
Thank you.
[MUSIC]