1 00:00:00,000 --> 00:00:01,200 [no audio] 2 00:00:01,200 --> 00:00:02,500 Friends, here we are going to 3 00:00:02,500 --> 00:00:05,900 discuss about Python functions concept, simply 4 00:00:05,900 --> 00:00:10,300 introduction part with your functions. Before going to work 5 00:00:10,300 --> 00:00:12,800 with your functions, 6 00:00:12,800 --> 00:00:16,399 let us assume that we have some code which consists of 7 00:00:16,399 --> 00:00:18,300 suppose some 150 lines. 8 00:00:18,300 --> 00:00:21,100 So I have 150 lines of code. 9 00:00:21,100 --> 00:00:24,300 And if you observe this entire code, somewhere I am repeating 10 00:00:24,300 --> 00:00:28,900 same logic in different places. 11 00:00:28,900 --> 00:00:32,799 Assume that, same logic I am repeating in 3 places. 12 00:00:32,799 --> 00:00:36,600 Assume that each logic consists of suppose some 30 lines. 13 00:00:36,600 --> 00:00:40,914 That means, the same 30 lines of logic you are repeating in 3 places. 14 00:00:40,914 --> 00:00:43,000 Not only 3, just assume that some number of 15 00:00:43,000 --> 00:00:45,300 times you are repeating same type of logic. 16 00:00:46,800 --> 00:00:54,400 Right. See if you are repeating the same logic in different places, 17 00:00:54,447 --> 00:01:00,049 in that case you don't need to write your logic in 3 places whenever 18 00:01:00,049 --> 00:01:03,900 if you are repeating. What we will do is, whatever 19 00:01:03,900 --> 00:01:06,400 the logic you are repeating no, that logic I will write 20 00:01:06,400 --> 00:01:09,500 in one place in my code itself, and I will give some name 21 00:01:09,500 --> 00:01:11,200 suppose for that 'mycode'. 22 00:01:11,200 --> 00:01:13,500 [no audio] 23 00:01:13,500 --> 00:01:16,400 And now what I will do is, I will remove these 30 lines of 24 00:01:16,400 --> 00:01:17,700 code in 3 places. 25 00:01:18,900 --> 00:01:20,000 Wherever you have 26 00:01:20,002 --> 00:01:24,900 30 lines of code, right, there simply I will write 'mycode'. 27 00:01:24,900 --> 00:01:28,110 I have given a name for 30 lines of code, 'mycode'. 28 00:01:28,100 --> 00:01:29,600 Now here I am giving 'mycode'. 29 00:01:29,600 --> 00:01:32,100 [no audio] 30 00:01:32,100 --> 00:01:33,100 'mycode', 31 00:01:34,800 --> 00:01:39,100 Right. Now guys, what I am doing is, see, actually you have 32 00:01:39,100 --> 00:01:44,488 150 lines of code, in this 150 lines of code, 30 + 30 + 30, 90, 33 00:01:44,488 --> 00:01:50,656 90 lines, plus remaining 60 lines, finally 150 lines of code. 34 00:01:50,600 --> 00:01:53,400 But 30 lines of code we are repeating in 3 places. 35 00:01:53,400 --> 00:01:55,500 That means, instead of these 90 lines, 36 00:01:55,500 --> 00:01:59,100 what we are doing is 30 lines of code 37 00:01:59,100 --> 00:02:00,100 I'm writing somewhere. 38 00:02:01,700 --> 00:02:06,400 Wherever this 30 lines of code is required, there 39 00:02:06,400 --> 00:02:10,800 I will write the name which I have given for this 30 lines of code. 40 00:02:10,800 --> 00:02:12,900 So, what is the name I have given? 'mycode'. 41 00:02:12,900 --> 00:02:15,300 So here I will write 'mycode'. Instead of 30 lines simply I'm writing only 42 00:02:15,300 --> 00:02:18,700 one line. So, you are saving 29 lines. 43 00:02:18,700 --> 00:02:23,400 You're reducing 29 lines in this place. Same way in this 30 44 00:02:23,400 --> 00:02:26,000 lines, I am removing these 30 lines. 45 00:02:26,000 --> 00:02:27,400 Simply I'm writing 'mycode'. 46 00:02:27,400 --> 00:02:30,200 That's it. I'm giving the name. 47 00:02:30,200 --> 00:02:33,700 Then again here also, reducing 29 lines. 48 00:02:33,700 --> 00:02:36,207 So then here also you are having 30 lines no, 49 00:02:36,207 --> 00:02:39,355 I am removing these 30 lines of code and simply 50 00:02:39,355 --> 00:02:41,900 I'm writing whatever the name I have given for this 30 lines, 51 00:02:41,900 --> 00:02:46,900 'mycode'. Then here also you are reducing 29 line numbers. 52 00:02:46,900 --> 00:02:51,500 So instead of 90 lines, now you are using only 3 lines, 53 00:02:51,500 --> 00:02:55,900 plus in the same code itself you are giving a name for your 54 00:02:55,900 --> 00:03:00,000 30 lines. 30 lines plus name, 31 lines. 55 00:03:00,000 --> 00:03:03,700 So finally you're writing 34 lines instead of 90 lines. 56 00:03:03,700 --> 00:03:06,000 [no audio] 57 00:03:06,000 --> 00:03:13,400 So you almost reduced 60, 56 lines, right? 58 00:03:13,400 --> 00:03:16,300 So you are able to reduce your length of the code. 59 00:03:16,300 --> 00:03:18,099 Let me give a simple example. 60 00:03:18,100 --> 00:03:20,200 You can easily understand that. Suppose 61 00:03:20,200 --> 00:03:22,900 I have a small requirement. The purpose of requirement, 62 00:03:22,900 --> 00:03:27,100 I mean the requirement is, whenever I run my Python script, 63 00:03:27,100 --> 00:03:30,000 it has to clear my command line, then it has to display the 64 00:03:30,000 --> 00:03:31,300 list of files and directories. 65 00:03:32,500 --> 00:03:34,400 Right. See that I am writing 66 00:03:34,400 --> 00:03:36,400 [no audio] 67 00:03:36,400 --> 00:03:37,400 something like, 68 00:03:38,400 --> 00:03:42,000 I need to run commands like 'cls', suppose Windows, 69 00:03:42,900 --> 00:03:46,800 I need to run 'cls' command, and then 'dir' command. Right. 70 00:03:46,800 --> 00:03:50,400 So, to run your commands, you have two options in your Python. 71 00:03:50,400 --> 00:03:52,700 'os.system()', and then sub-process module. 72 00:03:52,700 --> 00:03:56,700 Of course, you are also having 'os.popen', process open, 73 00:03:56,700 --> 00:04:00,500 but anyway, 'os.system()', and sub-process are the best 74 00:04:00,500 --> 00:04:02,300 [no audio] 75 00:04:02,300 --> 00:04:06,300 process to run your commands. And whenever you want to 76 00:04:06,300 --> 00:04:09,400 capture the output, then go with the sub-process. Just simply 77 00:04:09,400 --> 00:04:12,200 if you want to run the command, just go with 'os.system()'. 78 00:04:12,200 --> 00:04:13,700 That's why here my intention is, 79 00:04:13,790 --> 00:04:15,900 just I want to run the command. 80 00:04:15,900 --> 00:04:21,303 So, I am importing 'os'. So simply 'os.system("cls")' I am running. Then 81 00:04:21,303 --> 00:04:31,123 'os.system()', what I am running, 'dir' command, that's it. 82 00:04:31,100 --> 00:04:35,000 Now, let me go to command line. And then, so I have given script 83 00:04:35,000 --> 00:04:38,600 name as 'run_ your_commands.py'. Now let me run it. Yes. 84 00:04:38,600 --> 00:04:41,200 It's clearing your screen and it is displaying something. 85 00:04:42,500 --> 00:04:47,900 But I want to display something like 'print("Please wait")'. 86 00:04:49,100 --> 00:04:52,200 Actually, no need of this, just for clarity 87 00:04:52,200 --> 00:04:54,900 I'm giving number of lines. "Please wait. 88 00:04:54,900 --> 00:04:58,600 [no audio] 89 00:04:58,600 --> 00:05:01,700 Cleaning the screen". That's it. 90 00:05:02,700 --> 00:05:04,600 Then after this, 'print( 91 00:05:05,800 --> 00:05:12,600 "Please wait. Finding the list of directories and files")'. 92 00:05:12,600 --> 00:05:15,200 [no audio] 93 00:05:15,200 --> 00:05:16,900 That's it. Now, let me run it. 94 00:05:16,900 --> 00:05:18,900 [no audio] 95 00:05:18,900 --> 00:05:23,300 Yes, you are getting. But after displaying, "Please wait 96 00:05:23,300 --> 00:05:25,200 finding the list of directories and files", 97 00:05:25,200 --> 00:05:28,500 I want to wait for 2 seconds before executing the next line, 98 00:05:28,500 --> 00:05:31,900 I mean before executing this line. The same way 99 00:05:31,900 --> 00:05:33,500 after printing this line 100 00:05:33,500 --> 00:05:36,800 I want to wait for 2 seconds before executing this 101 00:05:36,800 --> 00:05:38,800 'os.system()', so that I can see this information. 102 00:05:38,800 --> 00:05:42,300 Otherwise, this information is also going to clean on your command line. 103 00:05:42,900 --> 00:05:47,000 So, to wait for sometime you have a 'time' module. 104 00:05:47,100 --> 00:05:49,600 Anyway, we'll discuss about 'time' module in detail. 105 00:05:49,600 --> 00:05:51,400 [no audio] 106 00:05:51,420 --> 00:05:53,300 So, what I am doing is, after displaying this 107 00:05:53,300 --> 00:05:56,400 messages, I don't want to go and execute next line, 108 00:05:56,400 --> 00:05:59,000 I want to wait for 2 seconds. 109 00:05:59,000 --> 00:06:03,100 I want to stop your process with your Python. Then simply 110 00:06:03,100 --> 00:06:05,771 'time.sleep(2)' seconds I want to wait. 111 00:06:05,700 --> 00:06:08,200 The same way after displaying this message, 112 00:06:09,600 --> 00:06:17,400 I want to wait again suppose, sorry 'time.sleep(2)' seconds. 113 00:06:17,700 --> 00:06:19,800 Right. Now, let me run it and see the output. 114 00:06:21,300 --> 00:06:24,200 So, it's waiting 2 seconds. Then after that, it is waiting 115 00:06:24,200 --> 00:06:25,800 again 2 seconds. Then you're getting your data. 116 00:06:26,400 --> 00:06:27,400 That's fine. 117 00:06:28,300 --> 00:06:32,500 Suppose if I copy this code, and if I try to run this on my 118 00:06:32,500 --> 00:06:33,500 Unix-like system, 119 00:06:33,500 --> 00:06:35,400 [no audio] 120 00:06:35,400 --> 00:06:41,700 Right. Let me write simply 'run_your_commands.py' script. 121 00:06:41,700 --> 00:06:43,800 So same script I am copying and pasting here. 122 00:06:45,100 --> 00:06:49,500 Will it work? See the result. So I want to run using Python 3. 123 00:06:49,500 --> 00:06:53,700 [no audio] 124 00:06:53,700 --> 00:06:57,500 See, 'cls' command is not working, because 'cls' is not the 125 00:06:57,500 --> 00:07:01,300 command to clear your command line of your Unix-like system. 126 00:07:01,300 --> 00:07:05,300 'clear' is the command, right? 127 00:07:06,000 --> 00:07:09,200 And anyway 'dir' is working. But I want to get in detail, 128 00:07:09,500 --> 00:07:12,900 in this way I want to get. Then you have to use 'ls - lrt'. 129 00:07:12,900 --> 00:07:16,500 So, on Windows you have 'cls' and 'dir'. For Unix 130 00:07:16,500 --> 00:07:20,700 I need 'clear' and 'ls -lrt' commands. 131 00:07:20,700 --> 00:07:24,800 So, what I am doing is, before running your commands 132 00:07:24,800 --> 00:07:29,355 I'm trying to identify the platform. You know there is a 'platform' module. 133 00:07:29,300 --> 00:07:31,600 And if you remember, we discussed already about this. 134 00:07:33,100 --> 00:07:38,300 Right. "Windows". So, if 'platform.system() == "Windows", 135 00:07:38,300 --> 00:07:40,300 then I want to run this logic. 136 00:07:40,300 --> 00:07:44,300 [no audio] 137 00:07:44,300 --> 00:07:45,300 See the logic. 138 00:07:45,300 --> 00:07:53,300 [no audio] 139 00:07:53,300 --> 00:07:58,900 That's it. 'else', if it is not Windows, what I am doing is, same logic 140 00:07:58,900 --> 00:08:02,600 but difference in commands. See that. 141 00:08:04,200 --> 00:08:11,000 Same logic, the only thing here 'clear', and here 'ls-lrt'. 142 00:08:12,300 --> 00:08:13,600 Now, first let me save it. 143 00:08:14,600 --> 00:08:16,500 So guys, how we designed our script? 144 00:08:17,100 --> 00:08:20,400 It's like a platform independent script. It will execute on 145 00:08:20,500 --> 00:08:22,600 your Windows, as well as Unix-like systems. 146 00:08:22,600 --> 00:08:27,000 And what is finally your purpose? Clear your screen, then 147 00:08:27,000 --> 00:08:31,200 list the directories and files in the current location. Yes. 148 00:08:31,200 --> 00:08:34,600 Now I am running our script. 149 00:08:34,600 --> 00:08:36,900 [no audio] 150 00:08:36,900 --> 00:08:40,299 "Clearing your screen...". Wait 2 seconds. "Finding list of directories 151 00:08:40,200 --> 00:08:42,200 and files." Then you are getting. Now, 152 00:08:42,299 --> 00:08:45,600 what I will do is, I am going to copy this script to your 153 00:08:45,600 --> 00:08:46,799 Unix-like system as well. 154 00:08:47,100 --> 00:08:51,600 So before that, let me clean your old data. Now I am going 155 00:08:51,600 --> 00:08:52,799 to open same script, 156 00:08:52,799 --> 00:08:56,000 I am going to copy and paste the code which you have 157 00:08:56,000 --> 00:09:01,700 on your Windows. Now same logic, same script I'm running now on 158 00:09:01,700 --> 00:09:03,700 your Windows, sorry, Unix-like system. 159 00:09:04,200 --> 00:09:05,300 Now it's working, see that. 160 00:09:07,000 --> 00:09:08,000 That's fine. 161 00:09:09,000 --> 00:09:12,400 But the problem is, if you observe your entire logic, 162 00:09:12,400 --> 00:09:14,100 if you observe your entire logic, 163 00:09:15,400 --> 00:09:19,800 see, if you clearly observe, this thing, 164 00:09:19,800 --> 00:09:22,500 [no audio] 165 00:09:22,500 --> 00:09:24,100 right, and this thing, 166 00:09:24,100 --> 00:09:27,100 [no audio] 167 00:09:27,100 --> 00:09:30,100 same logic you are repeating here and here. The only thing, 168 00:09:30,100 --> 00:09:34,200 commands are different. This command, this command is different. 169 00:09:34,200 --> 00:09:37,800 Windows, this command. Unix, this command. Windows 'dir' command, 170 00:09:37,800 --> 00:09:40,800 Linux 'ls -lrt' but remaining logic is same no. 171 00:09:42,300 --> 00:09:46,500 That means you are repeating same logic in two places. 172 00:09:47,561 --> 00:09:50,600 As of now, only in two places, maybe in real time you 173 00:09:50,600 --> 00:09:52,910 are going to repeat same kind of logic maybe 100 times, 174 00:09:52,900 --> 00:09:56,600 or 10 times, or 5 times, based on your requirement. 175 00:09:56,600 --> 00:09:58,400 [no audio] 176 00:09:58,400 --> 00:10:02,300 As of now, I am repeating my logic in two places. Forget about 177 00:10:02,300 --> 00:10:03,800 commands, logic is same no. 178 00:10:04,800 --> 00:10:10,200 So, what I will do is, in my code itself right, this logic, 179 00:10:10,200 --> 00:10:14,400 I will write somewhere with some name, with some name. 180 00:10:14,800 --> 00:10:17,500 I am giving name for that suppose 'mycode'. 181 00:10:17,500 --> 00:10:19,900 You can provide any name for that. 182 00:10:19,900 --> 00:10:22,432 Okay, we will learn in detail about how to 183 00:10:22,432 --> 00:10:24,500 define your name for your logic. 184 00:10:24,500 --> 00:10:26,900 Everything we'll learn while going forward. For time being just 185 00:10:26,900 --> 00:10:28,100 observe the logic. 186 00:10:28,100 --> 00:10:30,100 [no audio] 187 00:10:30,100 --> 00:10:31,100 That's it. 188 00:10:32,400 --> 00:10:35,600 Now instead of, now forget about this 'cls', 189 00:10:35,600 --> 00:10:39,000 I am taking that as 'cmd1', and I am taking this as 190 00:10:39,000 --> 00:10:40,400 'cmd2'. Okay. 191 00:10:40,400 --> 00:10:43,100 Don't worry why we are taking 'cmd1' and 'cmd2'. 192 00:10:43,100 --> 00:10:47,100 We'll discuss in detail while going forward. But here my intention 193 00:10:47,100 --> 00:10:50,900 is, if you are repeating the logic, why should we repeat that logic? 194 00:10:52,300 --> 00:10:53,900 I don't want to repeat. 195 00:10:53,900 --> 00:10:56,600 [no audio] 196 00:10:56,600 --> 00:11:00,200 Right. See, actually whatever the logic you are repeating, that I removed. 197 00:11:01,600 --> 00:11:03,800 Right. But this is the logic you are repeating, right, 198 00:11:03,800 --> 00:11:06,600 that's why what is the name you have given for this logic? 199 00:11:06,600 --> 00:11:07,900 This is the name you have given. 200 00:11:08,400 --> 00:11:11,100 That name I will write here and here. That's it. 201 00:11:11,600 --> 00:11:14,800 So that your logic is over, but how is it going to work? 202 00:11:14,800 --> 00:11:21,000 We'll discuss it. 'mycode', then here I'm also writing 'mycode'. 203 00:11:21,500 --> 00:11:24,400 Now internally Python will replace 204 00:11:24,400 --> 00:11:27,200 in place of 'mycode' this entire logic. 205 00:11:28,100 --> 00:11:29,900 Same code only, you are not disturbing anything. 206 00:11:29,900 --> 00:11:31,800 The only thing, you are reducing the number of lines. 207 00:11:33,000 --> 00:11:38,200 Instead of rewriting the same logic in different places, what we are 208 00:11:38,200 --> 00:11:42,200 doing? We are writing in one place, and we are giving some 209 00:11:42,200 --> 00:11:46,400 name for that. Whenever it is required in your code instead 210 00:11:46,400 --> 00:11:48,100 of writing that entire logic simple 211 00:11:48,100 --> 00:11:51,100 we're writing the name which you have given for your logic. 212 00:11:52,800 --> 00:11:55,600 Right. So for this, I have given a name called 'mycode'. 213 00:11:55,600 --> 00:11:56,900 That's what I am writing here and here. 214 00:11:58,200 --> 00:12:00,400 Now internally have to assume that 'mycode' is nothing but 215 00:12:00,400 --> 00:12:04,100 this entire lines you can assume in place of 'mycode', and 216 00:12:04,100 --> 00:12:07,300 here also in place of 'mycode', we can assume entirely these lines. 217 00:12:07,900 --> 00:12:10,900 So, finally you are not disturbing with your code. Right. 218 00:12:11,900 --> 00:12:15,000 Whenever I'm working with Windows, I need to run something 219 00:12:15,000 --> 00:12:19,500 like 'cls'. Don't worry how I am giving this syntax. 220 00:12:19,500 --> 00:12:21,210 Okay. Just observe the concept. That's it. 221 00:12:21,200 --> 00:12:22,400 We'll discuss in detail. 222 00:12:22,400 --> 00:12:28,200 [no audio] 223 00:12:28,200 --> 00:12:31,100 That's it. Let me save it. So guys what I am doing, 224 00:12:31,900 --> 00:12:35,300 observe that. The logic which you are repeating, that logic 225 00:12:35,300 --> 00:12:38,100 I have written somewhere, and I have given some name for that. 226 00:12:38,700 --> 00:12:42,100 So, in your code previously wherever you are using this logic 227 00:12:42,100 --> 00:12:44,800 in that place simply I am giving this name. That's it. 228 00:12:45,800 --> 00:12:48,600 Now let me run it. If it is working perfectly then 229 00:12:48,600 --> 00:12:51,000 the way which you used here, that's correct. 230 00:12:52,700 --> 00:12:56,100 Right. Yes, it's working. See that. 231 00:12:57,000 --> 00:13:00,500 That means, whatever the process we followed, that is correct. 232 00:13:01,000 --> 00:13:03,600 So if we follow this process, what is the advantage? You are 233 00:13:03,600 --> 00:13:07,600 going to reduce the number of lines, or in reverse way, you 234 00:13:07,600 --> 00:13:12,718 are able to reuse this logic any number of times in your code. 235 00:13:12,718 --> 00:13:15,100 That is the advantage. Wherever you need 236 00:13:15,100 --> 00:13:16,873 there you don't need to write it no, simply 237 00:13:16,800 --> 00:13:18,800 you are going to you use this name. 238 00:13:20,000 --> 00:13:22,800 Reusability. Right. Now, 239 00:13:22,800 --> 00:13:25,000 let me copy this code to your Unix-like systems as well. 240 00:13:25,000 --> 00:13:26,000 There also I want to run it. 241 00:13:26,000 --> 00:13:31,900 [no audio] 242 00:13:31,900 --> 00:13:33,200 Let me copy and paste it. 243 00:13:34,500 --> 00:13:35,800 Right. I'm going to run it. 244 00:13:36,400 --> 00:13:40,300 So here also it is going to work perfectly. See that. 245 00:13:40,300 --> 00:13:43,500 [no audio] 246 00:13:43,500 --> 00:13:44,500 That's it. 247 00:13:45,400 --> 00:13:52,500 Right. So guys, in case you use this concept, then this is called a function. 248 00:13:54,200 --> 00:13:57,600 And you can reuse this function any number of times in your 249 00:13:57,600 --> 00:13:59,400 code wherever it is required. 250 00:13:59,400 --> 00:14:01,300 [no audio] 251 00:14:01,300 --> 00:14:04,800 Right. So how to define, how to use them, all those things, we'll see. 252 00:14:04,800 --> 00:14:06,700 [no audio] 253 00:14:06,700 --> 00:14:08,400 Okay, and one more thing, 254 00:14:09,700 --> 00:14:11,600 this is a function. Simply, 255 00:14:11,600 --> 00:14:14,800 this is a function. You know function means some operation 256 00:14:14,800 --> 00:14:16,900 is there with function. That's it. Suppose if you take 257 00:14:16,900 --> 00:14:22,200 'f(x) = 3x + 2', 'f(x)' is a function, and its operation 258 00:14:22,200 --> 00:14:26,400 is '3x + 2'. Now here 'mycode' is a function. That is nothing 259 00:14:26,400 --> 00:14:30,000 but 'f(x)', if you compare with your mathematics. 'mycode' 260 00:14:30,000 --> 00:14:34,600 is a function that is 'f(x)'. Right. 'mycode' is simply 'f', here 261 00:14:34,600 --> 00:14:38,300 'cmd1', 'cmd2', assume that 'x'. Now based on 262 00:14:38,300 --> 00:14:39,800 'x' you are getting your 'f(x)' value 263 00:14:39,800 --> 00:14:44,500 by executing this '3x + 2' expression. The same way, based 264 00:14:44,500 --> 00:14:47,200 on 'cmd1' and 'cmd2', you're getting final result for 265 00:14:47,200 --> 00:14:49,700 your 'mycode', by executing this logic. 266 00:14:51,200 --> 00:14:54,000 Right. See, if you are good with your mathematics, 267 00:14:54,000 --> 00:14:58,500 it is very easy to compare. Just assume that '3x + 2' is nothing 268 00:14:58,500 --> 00:15:02,679 but this part, 'mycode' is nothing but 'f', 269 00:15:02,600 --> 00:15:04,700 and 'cmd1', 'cmd2' are nothing but 'x'. 270 00:15:05,866 --> 00:15:10,700 So '3x + 2' depends on 'x' value. So based on 271 00:15:10,700 --> 00:15:15,700 'x' value finally you are getting 'f(x)' value. The same way this 272 00:15:15,700 --> 00:15:18,400 logic depends on 'cmd1' and 'cmd2'. Based on this 273 00:15:18,400 --> 00:15:22,700 'cmd1' and 'cmd2', finally you are getting the result of 'mycode'. 274 00:15:22,700 --> 00:15:25,800 That's why this is simply a function. Same as your mathematics 275 00:15:25,800 --> 00:15:29,500 concepts. That is on paper. This is on memory. That's it. 276 00:15:30,500 --> 00:15:33,300 You're executing with your Python software. That's it. 277 00:15:34,300 --> 00:15:36,500 So this is a function. Right. 278 00:15:36,500 --> 00:15:39,300 This is some variables as of now, but not variables, 279 00:15:39,300 --> 00:15:43,100 we have some other name. We'll see that. In 'f(x)', 'f' is a function, 280 00:15:43,100 --> 00:15:44,600 'x' is the variable. Same way, 281 00:15:45,200 --> 00:15:47,800 this is a function in terms of 'cmd1' and 'cmd2'. 282 00:15:47,800 --> 00:15:48,800 That's it. 283 00:15:49,800 --> 00:15:54,300 Right. So finally, I want to give you the simple definition for 284 00:15:54,300 --> 00:15:58,800 your function. Function is a block of code for some specific 285 00:15:58,800 --> 00:16:00,634 operation. That operation may be anything 286 00:16:00,600 --> 00:16:03,300 based on your requirement in your situation. 287 00:16:04,700 --> 00:16:09,200 Right. Once if you define a function, you can reuse that. Any 288 00:16:09,200 --> 00:16:13,000 number of times you can use it in your code wherever it is required. 289 00:16:14,300 --> 00:16:18,900 Right. And a function executes only when it is called. 290 00:16:19,900 --> 00:16:20,900 See that. 291 00:16:21,600 --> 00:16:22,700 Let me remove this. 292 00:16:23,600 --> 00:16:26,500 Don't worry how to call, we'll discuss that. So as of now just 293 00:16:26,500 --> 00:16:29,600 I defined a function. Nowhere I am using this, right. 294 00:16:29,600 --> 00:16:30,600 Am I using it here? 295 00:16:31,000 --> 00:16:35,000 So, previously you where using here and here, 13th line, 15th line. 296 00:16:35,000 --> 00:16:38,000 Suppose if I comment this code, nowhere you are using that. 297 00:16:38,967 --> 00:16:43,200 If you are not using, then if you run your code, it won't 298 00:16:43,200 --> 00:16:46,310 execute. Even, let me run it on your command line, 299 00:16:46,300 --> 00:16:47,600 then you will get a clarity. 300 00:16:47,600 --> 00:16:49,600 [no audio] 301 00:16:49,600 --> 00:16:53,300 Right. It's not executing. Even though if you have a function, 302 00:16:54,000 --> 00:16:56,600 it won't execute by itself. 303 00:16:57,100 --> 00:17:00,100 If you want to execute a function, you should use that 304 00:17:00,100 --> 00:17:02,300 somewhere in your code. That's it. 305 00:17:02,300 --> 00:17:05,257 That is the concept of your function. Okay. 306 00:17:05,257 --> 00:17:09,852 So guys, this is simply introduction part with your functions, okay. 307 00:17:09,852 --> 00:17:12,300 In later videos we will go with step-by-step, 308 00:17:12,300 --> 00:17:15,800 and we will learn completely about your functions. Right. 309 00:17:15,800 --> 00:17:18,473 And then we will see how to use in real-time 310 00:17:18,400 --> 00:17:21,000 for different scenarios, okay. 311 00:17:21,500 --> 00:17:23,400 Okay guys, thank you for watching this video. 312 00:17:23,400 --> 00:17:28,640 [no audio]