1 00:00:07,710 --> 00:00:15,380 In the last exercise, we created a court that determines if a candidate is suitable for a work position 2 00:00:15,660 --> 00:00:23,250 and remember to ask for his degree, whether his masturbation or 15 in for his years of experience, 3 00:00:23,430 --> 00:00:29,310 and if if he hit more than two years of experience and education, hire the master. 4 00:00:29,490 --> 00:00:31,230 Then he was accepted for the interview. 5 00:00:31,590 --> 00:00:40,650 So this court here works, but I would like you to make it as a function so it can be easily used and 6 00:00:40,700 --> 00:00:42,930 Lambright to the requirements for that function. 7 00:00:44,390 --> 00:00:59,270 So the function here is to take the degree and experience of the candidate and then the function has 8 00:00:59,270 --> 00:01:06,720 to return whether the candidate is suitable for the role. 9 00:01:08,180 --> 00:01:15,900 OK, so stop this vigil for about five to 10 minutes, because we need to think how to do that, then 10 00:01:15,920 --> 00:01:18,410 big dysfunction that created in the last section. 11 00:01:19,560 --> 00:01:25,650 I mean, this lines of code and make them into a function, then this tour function by passing parameters 12 00:01:25,800 --> 00:01:27,090 and checking the results. 13 00:01:28,710 --> 00:01:33,080 Now, in order to create this code, you simply need to understand how to create a function. 14 00:01:33,240 --> 00:01:38,890 It's actually quite easy and it even simplifies the way that we created a code already. 15 00:01:39,180 --> 00:01:40,390 And you see how it's done. 16 00:01:40,590 --> 00:01:47,850 First of all, I will mark all the code and I will stop here in order to shift to the left to the right 17 00:01:47,850 --> 00:01:48,190 side. 18 00:01:48,660 --> 00:01:53,810 Then I'll write G.F. for function and the function will be called work. 19 00:01:54,300 --> 00:02:01,650 So the values rule passages function, as I told you, are going to be degree and experience. 20 00:02:02,670 --> 00:02:02,980 Right. 21 00:02:03,450 --> 00:02:07,890 So since we're passing this virus, actually we don't need the first two lines. 22 00:02:07,890 --> 00:02:08,200 Right. 23 00:02:09,120 --> 00:02:12,110 We don't need to ask for this because we're going to pass it already. 24 00:02:12,780 --> 00:02:13,720 So I remove them. 25 00:02:14,040 --> 00:02:17,650 And now, if you prefer the simple way, OK. 26 00:02:18,210 --> 00:02:23,370 In this case, the most simple way will be to leave the function like this, because you already wrote 27 00:02:23,370 --> 00:02:24,600 the print statements here. 28 00:02:24,750 --> 00:02:25,120 Right. 29 00:02:25,830 --> 00:02:31,200 So I can just call this function with the certain about this. 30 00:02:31,200 --> 00:02:31,560 Right. 31 00:02:33,110 --> 00:02:43,150 Work and then the degree it's going to be master and the experience is going to be five years, so what 32 00:02:43,160 --> 00:02:49,880 we expect here is to see that we are accepted for the interview, this key, and you can see that you 33 00:02:49,880 --> 00:02:51,090 are separate for the interview. 34 00:02:51,440 --> 00:02:59,030 So what actually happened is that we basically passed the muster degree in the five years of experience 35 00:02:59,330 --> 00:03:00,370 to this if I was here. 36 00:03:00,650 --> 00:03:06,350 And then we called our if loop statements now. 37 00:03:06,530 --> 00:03:09,910 But you mentioned that you didn't have your coat in front of you. 38 00:03:09,910 --> 00:03:12,620 Imagine that you wanted to create a functional from scratch. 39 00:03:12,980 --> 00:03:16,670 Then this will definitely not be the most simple way because. 40 00:03:18,110 --> 00:03:24,040 You are not giving an output from this function and would like to give an output from this function, 41 00:03:24,260 --> 00:03:26,590 so I remove the print statements here. 42 00:03:27,870 --> 00:03:35,510 Instead, I try to return and simply remove the print statements, remove the brackets, and I return 43 00:03:35,510 --> 00:03:36,530 here, OK? 44 00:03:37,100 --> 00:03:43,510 And then when you want to actually print what is going to be the answer, in the end, you can write, 45 00:03:44,150 --> 00:03:48,350 print and then in the brackets what is return from this function. 46 00:03:48,590 --> 00:03:54,460 So if I run the code now, so Python run, you can see that we are getting the same result. 47 00:03:54,680 --> 00:03:57,500 But now our function here, the actual output.