1 00:00:00,800 --> 00:00:07,090 We are going to discuss Biton closer's, so indecision at first we shall define what is a python. 2 00:00:07,110 --> 00:00:11,880 Clouzot then you should explain it with one demonstration for the understanding. 3 00:00:12,410 --> 00:00:15,410 So here is the definition of python. 4 00:00:15,410 --> 00:00:16,930 Closer it close. 5 00:00:16,940 --> 00:00:23,810 It is a function object that remembers the values in including scopes, even if they are not present 6 00:00:24,440 --> 00:00:28,010 in the memory, I think to have the better clarity. 7 00:00:28,040 --> 00:00:34,010 Let us explain it with one practical demonstration to implement disclosers in Python. 8 00:00:34,850 --> 00:00:42,470 Before getting that detailed idea, what is the closer we must be having a crystal clear idea regarding 9 00:00:42,470 --> 00:00:46,960 that, what is that nested function and what is nonlocal variable? 10 00:00:47,420 --> 00:00:52,640 So we should have the understanding that what is that nested function and what is a nonlocal variable 11 00:00:53,030 --> 00:00:55,310 before going for discloser functions. 12 00:00:55,550 --> 00:00:57,050 It function will be defined. 13 00:00:57,050 --> 00:01:02,360 If it is defined inside out of the function, then obviously that function will be called as a nested 14 00:01:02,360 --> 00:01:02,810 function. 15 00:01:03,230 --> 00:01:08,960 Nested functions can access variables of the enclosing scope, will be discussing all these things, 16 00:01:08,960 --> 00:01:10,070 using this example. 17 00:01:10,400 --> 00:01:15,770 So now here to see this is our one method is there and within this method we have to find out of the 18 00:01:15,770 --> 00:01:16,190 method. 19 00:01:16,520 --> 00:01:20,330 So this is this method will be called as the nested method. 20 00:01:20,600 --> 00:01:27,170 Nested function and business to function can access the variables, which is within the scope that is 21 00:01:27,350 --> 00:01:30,240 within the inclosing scope in Python. 22 00:01:30,260 --> 00:01:37,520 This nonlocal variables are read-only by default, and we must declare them explicitly as nonlocal and 23 00:01:37,520 --> 00:01:42,240 to in order to modify them for in order to object with some new halloo. 24 00:01:42,680 --> 00:01:44,810 So let us go for one example here. 25 00:01:45,200 --> 00:01:47,000 So here you have defined one method. 26 00:01:47,000 --> 00:01:48,150 That is a message. 27 00:01:48,170 --> 00:01:52,850 We stick this message as input parameter and we have defined one nested method. 28 00:01:52,850 --> 00:01:56,180 That is the print message inor intentionally. 29 00:01:56,180 --> 00:02:01,480 I've given this name of this method as print message inor and which print this message. 30 00:02:01,490 --> 00:02:05,080 You see this message is defined in this inclosing scope. 31 00:02:05,090 --> 00:02:08,840 So that's why this message can be accessed from this inner method. 32 00:02:09,170 --> 00:02:11,420 So now return print message innot. 33 00:02:11,420 --> 00:02:14,430 So this inner function has been returned here. 34 00:02:14,870 --> 00:02:16,140 So now how to access it. 35 00:02:16,460 --> 00:02:22,010 So here to see we are calling this method that is the outer method, that is the print message and passing 36 00:02:22,010 --> 00:02:22,620 the screen. 37 00:02:23,330 --> 00:02:28,970 There is a hello, this string we are passing which will be assigned to this message and now it is its 38 00:02:28,970 --> 00:02:31,300 output will be will be taken into available. 39 00:02:31,520 --> 00:02:32,520 Let it be another. 40 00:02:32,930 --> 00:02:37,610 So this another is actually containing the reference of this inner method. 41 00:02:37,610 --> 00:02:39,330 That is a print message inor. 42 00:02:39,620 --> 00:02:45,410 So from there, if you call that is another method then this hello is getting printed and there is a 43 00:02:45,410 --> 00:02:49,010 feature of discloser has got implemented in this example. 44 00:02:49,550 --> 00:02:52,770 So let us go for another example for the better understanding. 45 00:02:53,180 --> 00:02:55,420 So here to see here, you have to find one method. 46 00:02:55,430 --> 00:03:02,240 There is a multiplier outr having this N as the input parameter and that is one nested method. 47 00:03:02,240 --> 00:03:06,010 Is there nested function, is there there is a multiplier underscored in it. 48 00:03:06,530 --> 00:03:14,060 So this by method requires one input argument that is about X and this outer variable that is a nonlocal 49 00:03:14,060 --> 00:03:19,040 variable that is out in can be accessed from this multiplied inner function. 50 00:03:19,280 --> 00:03:24,350 So return Eckstut n and it returns this nested method as output. 51 00:03:24,830 --> 00:03:30,260 So now we are calling this outer a multipolar outer function with this parameter three, this parameter 52 00:03:30,260 --> 00:03:32,340 three will be assigned to this in here. 53 00:03:32,600 --> 00:03:34,790 So it is it has been assigned two times three. 54 00:03:34,790 --> 00:03:39,920 It has been the same two times five when the five has been has been passed as the input parameter. 55 00:03:40,400 --> 00:03:42,380 So now you see the inner method. 56 00:03:42,380 --> 00:03:45,870 There is a multiplier equals one parameter for its execution. 57 00:03:46,220 --> 00:03:49,140 So here we are calling this one as times three nine. 58 00:03:49,550 --> 00:03:56,090 So here you can find that N has got initialized with three and this X has got initialized with this 59 00:03:56,090 --> 00:03:56,540 nine. 60 00:03:56,720 --> 00:04:00,590 So whenever I'm just executing this one, it should print 27. 61 00:04:00,920 --> 00:04:06,290 So now let me execute the code here so you can see that it is printing 27. 62 00:04:06,290 --> 00:04:11,130 It it is printing 27 because it is actually multiplying three and nine. 63 00:04:11,570 --> 00:04:17,450 So in this particular call, you can find that this five is getting assigned to this end so that now 64 00:04:17,450 --> 00:04:19,820 there is at times five, so times five, three. 65 00:04:19,830 --> 00:04:24,350 So these three will be assigned to X, so three into five. 66 00:04:24,410 --> 00:04:29,360 So that's why it will return the respective 15 trying to five to return the respective 15. 67 00:04:29,780 --> 00:04:31,100 So now consider this one. 68 00:04:31,580 --> 00:04:33,560 So now here you see times three. 69 00:04:33,560 --> 00:04:35,540 So N has got the value three. 70 00:04:35,570 --> 00:04:37,350 And here we are passing this to here. 71 00:04:37,730 --> 00:04:39,050 So then what is the value here. 72 00:04:39,080 --> 00:04:40,100 So two into three. 73 00:04:40,100 --> 00:04:43,670 Six so six will be the input arguing for these times. 74 00:04:43,670 --> 00:04:44,030 Five. 75 00:04:44,030 --> 00:04:50,720 So five has got assigned to this end already because times five we pass this fight over this multiple 76 00:04:50,720 --> 00:04:51,890 output method. 77 00:04:52,070 --> 00:04:54,660 So that's why the five has got assigned to an already. 78 00:04:54,920 --> 00:05:01,370 And here you are having the six and the six will be assigned to this X and then X into N, so that means 79 00:05:01,520 --> 00:05:02,590 six into five. 80 00:05:02,600 --> 00:05:04,760 So will be the required outcome. 81 00:05:05,120 --> 00:05:10,940 So in this way, in this particular example, we have defined that how this KLOSER functions can be 82 00:05:10,940 --> 00:05:12,320 used in our python coding. 83 00:05:12,920 --> 00:05:14,270 Thanks for watching this video.