1 00:00:00,220 --> 00:00:08,100 Right now, it is time to share the functions and the functions, to write a specific commands or specific 2 00:00:08,100 --> 00:00:11,790 instructions, and then you call that function over and over. 3 00:00:11,820 --> 00:00:15,510 You don't need to write and rewrite everything over and over. 4 00:00:16,110 --> 00:00:20,030 So, for example, you add tin to specific then. 5 00:00:20,250 --> 00:00:20,600 OK. 6 00:00:20,640 --> 00:00:23,550 OK, by the way, we already saw functions. 7 00:00:24,150 --> 00:00:30,930 You know, by the way, print is a function, APS is a function, the end is a function with this that 8 00:00:30,930 --> 00:00:32,040 converts the value. 9 00:00:32,430 --> 00:00:36,300 That's the arm that we saw is an esan function. 10 00:00:36,600 --> 00:00:39,450 OK, but these are called built in function. 11 00:00:39,570 --> 00:00:44,290 And what we are going to do is write a customized function. 12 00:00:44,550 --> 00:00:50,310 So I want to add function to add 10 to the value that I but or I. 13 00:00:50,760 --> 00:00:52,050 OK, so how to do that. 14 00:00:52,180 --> 00:00:54,630 Actually before that, let's have a look on the syntax. 15 00:00:54,900 --> 00:00:56,010 The syntax is like this. 16 00:00:56,220 --> 00:00:58,530 You type the name def which means define. 17 00:00:59,490 --> 00:01:02,180 And the name of the function, its name, one one. 18 00:01:02,490 --> 00:01:08,320 OK, open the brackets and inside the brackets we have bar one, bar two. 19 00:01:08,370 --> 00:01:10,410 So these are called parameters. 20 00:01:10,710 --> 00:01:14,250 These are values that can be best when we call this function. 21 00:01:14,550 --> 00:01:17,460 We would have we would have that and we see it now. 22 00:01:17,490 --> 00:01:19,340 I would open the curtain here. 23 00:01:19,830 --> 00:01:26,400 Actually, I think you are getting familiar with Python now because you can see that these are the same 24 00:01:26,400 --> 00:01:32,310 thing that used when we used if condition while before and so on. 25 00:01:32,430 --> 00:01:40,340 OK, we can just open the brackets and put the current here and we need to do to put it inside the indentation. 26 00:01:40,710 --> 00:01:42,330 OK, now we're inside it. 27 00:01:42,330 --> 00:01:46,170 Let's print this is inside one one. 28 00:01:46,640 --> 00:01:47,850 Right, OK. 29 00:01:48,760 --> 00:01:57,310 OK, now also we can have a return value so we can return value return, for example, or right or return 30 00:01:57,970 --> 00:02:02,140 function or return variable that we defined here inside the function. 31 00:02:02,380 --> 00:02:05,650 So if I type or if I declared I equals zero. 32 00:02:06,660 --> 00:02:10,170 And if I return it here, so return. 33 00:02:10,860 --> 00:02:11,960 So this would return unusual. 34 00:02:12,420 --> 00:02:14,400 So this function will print. 35 00:02:14,430 --> 00:02:19,840 This is inside phone one and it will return I, which is the value of zero. 36 00:02:20,380 --> 00:02:27,150 Now, how to call this function actually now just as simple as that, I would name I would put the name 37 00:02:27,150 --> 00:02:28,950 of the function which is fun one. 38 00:02:29,190 --> 00:02:29,510 Right. 39 00:02:29,970 --> 00:02:35,420 But you can see we are required to add part parameters because we have Barwan and Bertka. 40 00:02:35,760 --> 00:02:40,040 But for now, let's do this like that and let's see what will happen. 41 00:02:40,300 --> 00:02:40,790 All right. 42 00:02:41,580 --> 00:02:44,860 By the way, the value return equation. 43 00:02:45,570 --> 00:02:47,160 It will be here, so. 44 00:02:48,180 --> 00:02:50,170 Let's have a look at what will happen. 45 00:02:51,270 --> 00:02:53,580 You can see this is inside one one. 46 00:02:53,590 --> 00:02:55,540 Yeah, but the thing is not here. 47 00:02:55,630 --> 00:02:55,920 Why? 48 00:02:55,930 --> 00:02:59,430 Because we didn't print it out, so I printed it out like this. 49 00:03:00,530 --> 00:03:07,430 Using the brain function, no, if I return here and run it again now, this time not this is inside 50 00:03:07,460 --> 00:03:11,060 one one only, but we have the value of AI, which is zero. 51 00:03:11,360 --> 00:03:12,540 OK, so far so good. 52 00:03:12,870 --> 00:03:14,110 Now let's have another thing. 53 00:03:14,390 --> 00:03:16,390 OK, now what if we have a barometer. 54 00:03:16,670 --> 00:03:17,960 So here. 55 00:03:19,230 --> 00:03:22,880 Bar one and we have bar two, OK? 56 00:03:23,130 --> 00:03:30,690 And this will return I plus bar one plus bar two, OK, so far so good. 57 00:03:30,690 --> 00:03:30,970 Right. 58 00:03:31,140 --> 00:03:33,300 And when I return or I. 59 00:03:34,640 --> 00:03:41,180 The function I need to provide value, so I will provide for the bar one so simple, right. 60 00:03:41,480 --> 00:03:43,530 And 20 for the bar too. 61 00:03:43,700 --> 00:03:45,890 And as you can see, it is integer and integer. 62 00:03:46,130 --> 00:03:53,480 Right now, this is what we will receive and we will get 10 plus 20 plus zero, which means 30. 63 00:03:53,570 --> 00:04:00,550 OK, so let's have a look here and let's run it so you can see it is 30 as expected, right? 64 00:04:01,070 --> 00:04:01,340 Yeah. 65 00:04:01,340 --> 00:04:04,520 By the way, if I print, I hear. 66 00:04:06,080 --> 00:04:07,100 Let's put the brackets. 67 00:04:07,240 --> 00:04:11,610 Yeah, I hear, yeah, let's have a look what happened, actually. 68 00:04:13,730 --> 00:04:16,010 Yeah, you can see that eye is not defined. 69 00:04:16,250 --> 00:04:16,970 Why is that? 70 00:04:17,180 --> 00:04:22,250 Because I is inside the scope or the indentation block of this function only. 71 00:04:22,520 --> 00:04:24,580 So this is a local variable. 72 00:04:24,890 --> 00:04:27,220 But if I define it here. 73 00:04:27,740 --> 00:04:28,160 All right. 74 00:04:28,160 --> 00:04:29,060 Let's have a look here. 75 00:04:29,240 --> 00:04:34,760 So if I define it here, I equal 10 or 11 this time. 76 00:04:35,420 --> 00:04:37,580 Now I value will be 11. 77 00:04:37,880 --> 00:04:45,180 But the precedence when we are inside the front one is go to the local variables, which is the equation. 78 00:04:45,440 --> 00:04:49,160 So here zero blastin plus thirty plus twenty sorry. 79 00:04:49,400 --> 00:04:50,720 Which means the value will be thirty. 80 00:04:50,900 --> 00:04:56,620 But when I receive it here I will not print that one inside the front one. 81 00:04:56,810 --> 00:04:59,510 No I will print it that the one that global. 82 00:04:59,530 --> 00:04:59,600 Global. 83 00:05:00,320 --> 00:05:04,930 OK, let's have a look what we what we will receive now. 84 00:05:05,010 --> 00:05:08,810 This time the first eye is equal 10 or 11. 85 00:05:10,130 --> 00:05:17,180 You can see that this inside one N30, so which means that we didn't do that, actually, if I remove 86 00:05:17,180 --> 00:05:20,180 that and I returned only the value of. 87 00:05:21,680 --> 00:05:24,410 Like this, so this should return zero. 88 00:05:25,340 --> 00:05:25,790 Only. 89 00:05:26,920 --> 00:05:29,680 OK, and actually, let's bring this inside. 90 00:05:30,710 --> 00:05:37,040 You can see that, yeah, I'm pretty sure you are getting the idea, but it's good to have practice 91 00:05:37,040 --> 00:05:37,630 on that. 92 00:05:37,640 --> 00:05:50,480 So I bought one about two suja like this so you can see that I hear would be so the printed one, but 93 00:05:51,350 --> 00:05:57,300 the print right outside the function will be irrelevant because this will use that lovenheim. 94 00:05:57,850 --> 00:05:59,990 OK, you can see that year 11. 95 00:06:00,290 --> 00:06:04,340 This is inside one one and the inside fund one is zero. 96 00:06:04,630 --> 00:06:06,230 OK, which is this one. 97 00:06:06,980 --> 00:06:11,720 The return value would be 30, which is zero blastin plus 20. 98 00:06:12,050 --> 00:06:13,360 The parameters we Besse. 99 00:06:13,610 --> 00:06:13,980 OK. 100 00:06:14,390 --> 00:06:14,830 All right. 101 00:06:14,870 --> 00:06:15,630 So far, so good. 102 00:06:15,860 --> 00:06:16,580 Thanks for watching.