In the last exercise, we created a court that determines if a candidate is suitable for a work position
and remember to ask for his degree, whether his masturbation or 15 in for his years of experience,
and if if he hit more than two years of experience and education, hire the master.
Then he was accepted for the interview.
So this court here works, but I would like you to make it as a function so it can be easily used and
Lambright to the requirements for that function.
So the function here is to take the degree and experience of the candidate and then the function has
to return whether the candidate is suitable for the role.
OK, so stop this vigil for about five to 10 minutes, because we need to think how to do that, then
big dysfunction that created in the last section.
I mean, this lines of code and make them into a function, then this tour function by passing parameters
and checking the results.
Now, in order to create this code, you simply need to understand how to create a function.
It's actually quite easy and it even simplifies the way that we created a code already.
And you see how it's done.
First of all, I will mark all the code and I will stop here in order to shift to the left to the right
side.
Then I'll write G.F. for function and the function will be called work.
So the values rule passages function, as I told you, are going to be degree and experience.
Right.
So since we're passing this virus, actually we don't need the first two lines.
Right.
We don't need to ask for this because we're going to pass it already.
So I remove them.
And now, if you prefer the simple way, OK.
In this case, the most simple way will be to leave the function like this, because you already wrote
the print statements here.
Right.
So I can just call this function with the certain about this.
Right.
Work and then the degree it's going to be master and the experience is going to be five years, so what
we expect here is to see that we are accepted for the interview, this key, and you can see that you
are separate for the interview.
So what actually happened is that we basically passed the muster degree in the five years of experience
to this if I was here.
And then we called our if loop statements now.
But you mentioned that you didn't have your coat in front of you.
Imagine that you wanted to create a functional from scratch.
Then this will definitely not be the most simple way because.
You are not giving an output from this function and would like to give an output from this function,
so I remove the print statements here.
Instead, I try to return and simply remove the print statements, remove the brackets, and I return
here, OK?
And then when you want to actually print what is going to be the answer, in the end, you can write,
print and then in the brackets what is return from this function.
So if I run the code now, so Python run, you can see that we are getting the same result.
But now our function here, the actual output.