Now we're going to introduce functions, we have seen functions as well and all the other programming
languages we have worked with.
So in order to define a function, all we need to do is simply just say this.
And then the name of the function, lets say calculate.
Just put parentheses and here you can pass whatever arguments you want, let's say, over the past two
arguments here and then here we can, let's say, return in order to exit the function.
I'm going to return A plus B, OK?
We can do whatever operations we want as long as we have an intent here and we can write all the functionality
inside.
You know, you might ask.
There is no main right.
There is no main.
The main could be written floating like this.
You could just say A equals seven or let's say X equals seven.
Y equals one, and then he you can say calculate X Y, OK, so you are sending X and Y here to calculate
and then it's returning and B. So you need to assign the result here to something.
So I'm going to say your result equals two.
Calculate X and Y.
OK, and just going to print this, so I'm going to print.
So we define the function.
We are getting two arguments to it and we are adding these two arguments.
You can, as I said, depending on the function, you can write whatever functionality you want all
the way here.
In my case, this functional just return the addition of two numbers, then this is the main as long
as it is outside the def and there is no intent.
This where the main start you'll say X equals seven, let's say equals one.
And here you are calling calculate.
We are calling it with two parameters X and Y which will be replacing and B.
And it will return A plus B, so it is returning a result that saving it get resolved here.
So let us see what's going to happen and the result is actually aid.
And that's correct.
So this is the basic functionality of functions.
If you have any questions, please write to me in the Q&A or you can write me an e-mail.