1 00:00:00,000 --> 00:00:01,300 Friends here we are going to 2 00:00:01,300 --> 00:00:04,700 discuss about how to define a function, and 3 00:00:04,700 --> 00:00:09,200 how to use or call or execute defined function. 4 00:00:10,500 --> 00:00:13,400 Right. Let me explain this with examples. 5 00:00:14,500 --> 00:00:20,000 So let me create a simple script to define and to use your 6 00:00:20,000 --> 00:00:27,000 function. So 'define_function.py'. 7 00:00:27,000 --> 00:00:29,400 [no audio] 8 00:00:29,400 --> 00:00:33,900 See that. If you want to define a function, you have to use 9 00:00:33,900 --> 00:00:35,400 keyword called 'def'. 10 00:00:36,800 --> 00:00:40,400 With that keyword you need to define your function, and anyway guys before 11 00:00:40,400 --> 00:00:44,100 going to work with functions, why we need a function? Whenever 12 00:00:44,100 --> 00:00:47,600 if you have repeated logic in your code, instead of 13 00:00:47,600 --> 00:00:50,100 repeating your logic in different places 14 00:00:50,100 --> 00:00:52,800 we are going to write that logic in one place, and we are 15 00:00:52,800 --> 00:00:53,800 giving some name. 16 00:00:53,800 --> 00:00:55,600 [no audio] 17 00:00:55,600 --> 00:00:57,900 So giving name is nothing but defining a function. 18 00:00:59,500 --> 00:01:03,800 Right. So I am defining simply 'display' function. That's it. 19 00:01:04,800 --> 00:01:05,800 Assume that 20 00:01:07,300 --> 00:01:10,400 I'm repeating two lines of code in different places. Now instead 21 00:01:10,400 --> 00:01:12,600 of writing two lines of code in different places, 22 00:01:12,600 --> 00:01:15,100 what I am doing is, those two lines I am writing here. 23 00:01:15,800 --> 00:01:18,700 So, "This is first line", just assumption. 24 00:01:19,400 --> 00:01:20,400 "This is second line". 25 00:01:20,900 --> 00:01:25,000 So these two lines I am repeating suppose in ten places, instead 26 00:01:25,000 --> 00:01:26,400 of repeating in ten places 27 00:01:26,400 --> 00:01:28,400 I am writing two lines here, and I am giving the name for 28 00:01:28,400 --> 00:01:32,100 that. So this is the way how to define a function. You have 29 00:01:32,100 --> 00:01:36,500 to define your function with 'def' keyword. 'def', your function 30 00:01:36,500 --> 00:01:38,500 name, then parentheses, after that colon. 31 00:01:39,800 --> 00:01:42,900 Guys, actually you are defining for these two lines 32 00:01:43,100 --> 00:01:44,900 you are giving one name called 'display'. 33 00:01:45,000 --> 00:01:47,600 That means these two lines are there under 'display'. 34 00:01:48,100 --> 00:01:52,200 So whenever if you want to write some lines under your function, 35 00:01:52,700 --> 00:01:57,500 you should provide some indentation, or some space for all 36 00:01:57,500 --> 00:01:59,900 your lines which are there under your function. 37 00:01:59,900 --> 00:02:02,100 [no audio] 38 00:02:02,100 --> 00:02:04,800 If you define any function without any line there is no use. 39 00:02:04,800 --> 00:02:07,600 [no audio] 40 00:02:07,600 --> 00:02:08,600 Right. See that. 41 00:02:08,699 --> 00:02:10,300 I am defining in this way. 42 00:02:11,300 --> 00:02:13,800 Your Python will give an error. What is that error? 43 00:02:14,800 --> 00:02:17,900 "SyntaxError: unexpected EOF while parsing". 44 00:02:17,900 --> 00:02:19,100 You don't have anything, 45 00:02:19,200 --> 00:02:20,300 that's why it is giving an error. 46 00:02:20,300 --> 00:02:22,300 [no audio] 47 00:02:22,300 --> 00:02:25,900 You should have at least one line inside of your function. 48 00:02:26,600 --> 00:02:27,800 Now, I have two lines. 49 00:02:28,200 --> 00:02:29,700 No problem. Yes, it's fine. 50 00:02:29,700 --> 00:02:31,800 [no audio] 51 00:02:31,800 --> 00:02:35,000 So I defined a function, and then I am running my Python script. 52 00:02:35,000 --> 00:02:36,600 You're not getting any output. 53 00:02:36,600 --> 00:02:38,900 [no audio] 54 00:02:38,900 --> 00:02:42,400 So whenever if we define a function, it won't execute by 55 00:02:42,400 --> 00:02:47,800 itself. If you want to run your Python function you should 56 00:02:47,800 --> 00:02:49,900 call somewhere. 57 00:02:50,200 --> 00:02:54,300 So let's say I am calling that function from sixth line, 'display'. 58 00:02:55,600 --> 00:02:57,100 Now let me run it. Now, 59 00:02:57,100 --> 00:02:59,200 you're going to get your two lines of output. 60 00:03:00,400 --> 00:03:03,600 So guys whenever your Python is running your code, how it 61 00:03:03,600 --> 00:03:05,800 is going to run? From top to down. 62 00:03:07,000 --> 00:03:10,800 So whenever it is coming from top to down, if Python identifies 63 00:03:10,800 --> 00:03:14,800 a keyword called 'def', then at that time your Python won't 64 00:03:14,800 --> 00:03:19,300 execute this logic, simply it will remember the name of your 65 00:03:19,300 --> 00:03:20,300 function name. 66 00:03:21,300 --> 00:03:24,300 Then it will come out from your function. 67 00:03:25,400 --> 00:03:26,500 Then do you have any line here? 68 00:03:26,500 --> 00:03:27,700 No problem, you don't have any line here. 69 00:03:27,700 --> 00:03:28,800 Now, we have a line here, 70 00:03:28,800 --> 00:03:32,600 but this line is 'display'. Already Python knows that 'display' is 71 00:03:32,600 --> 00:03:34,100 somewhere a function. 72 00:03:34,200 --> 00:03:37,900 That's why whenever 'display' is there, because already Python 73 00:03:37,900 --> 00:03:41,000 knows that where 'display' is there, now your Python flow of 74 00:03:41,000 --> 00:03:45,600 control, execution part will come to here, and now will execute 75 00:03:45,600 --> 00:03:48,800 these two lines. After completion of these two lines, again 76 00:03:48,800 --> 00:03:52,700 it will come to the same line, it will come automatically to sixth line itself. 77 00:03:52,700 --> 00:03:55,700 Then it will try to go to seventh line if you have any line here. 78 00:03:56,400 --> 00:03:57,800 As of now we don't have any seventh line. 79 00:03:59,000 --> 00:04:02,800 Right. So now what I am doing is, I am going to call it once again. 80 00:04:02,800 --> 00:04:05,500 [no audio] 81 00:04:05,500 --> 00:04:08,000 See that. So what you are doing? 82 00:04:08,000 --> 00:04:10,500 [no audio] 83 00:04:10,500 --> 00:04:12,200 You're calling first your function, 84 00:04:12,400 --> 00:04:14,400 then you are coming back to here only, then you're going to 85 00:04:14,400 --> 00:04:16,600 seventh line. Seventh line, again you're calling same function. 86 00:04:17,399 --> 00:04:20,000 Then you come back to here. Then you'll go to eighth line. As 87 00:04:20,000 --> 00:04:21,700 of now you don't have any eighth line. If you have it 88 00:04:21,700 --> 00:04:23,700 will, it may be any line, eighth line. 89 00:04:23,700 --> 00:04:27,200 Let's say I am going to print, "Now, we called 90 00:04:28,900 --> 00:04:32,400 display function two times". 91 00:04:32,400 --> 00:04:34,400 [no audio] 92 00:04:34,400 --> 00:04:35,600 Now once again, I'm going to call 93 00:04:35,600 --> 00:04:37,200 it. Yes, you can call it. No problem. 94 00:04:37,200 --> 00:04:39,000 [no audio] 95 00:04:39,000 --> 00:04:43,200 Right. So if I run my code, first thing, very first line is a 'def'. 96 00:04:43,200 --> 00:04:45,400 That's why Python won't execute this 'display' function. 97 00:04:45,900 --> 00:04:49,400 Simply it will remember the name where your 'display' is there, then 98 00:04:49,400 --> 00:04:51,600 it'll come out from your function, then is there anything 99 00:04:51,600 --> 00:04:52,800 here? No. Here 'display' 100 00:04:52,800 --> 00:04:55,200 is there. Now your Python will go to here, and it'll execute 101 00:04:55,200 --> 00:04:58,300 that, and will come back to same line. Then 102 00:04:58,300 --> 00:05:00,200 anyway, you don't have anything to execute in the same line. 103 00:05:00,200 --> 00:05:01,800 Then it'll, Python will go to seventh line. 104 00:05:01,900 --> 00:05:04,700 Now again 'display'. 'display' is a function. Now your python will 105 00:05:04,700 --> 00:05:07,000 come here, and will execute these two lines. 106 00:05:07,800 --> 00:05:10,800 Then it'll come back to same line, seventh line. As of now 107 00:05:10,800 --> 00:05:13,600 once again you don't have anything to do on seventh line. 108 00:05:13,700 --> 00:05:16,400 Then it will go to eighth line. Eighth is a 'print' statement. 109 00:05:16,400 --> 00:05:17,500 It'll print that line. 110 00:05:18,200 --> 00:05:20,600 Then it'll will go to ninth line. Ninth is again a function. 111 00:05:20,600 --> 00:05:23,000 Now, you will come to here, you will execute these two lines, and 112 00:05:23,000 --> 00:05:25,200 it'll come back to here, after that 113 00:05:25,200 --> 00:05:27,900 we don't have any lines, then your Python script will stop. 114 00:05:29,100 --> 00:05:31,800 Now, let me run it and see the output. That's it. 115 00:05:31,800 --> 00:05:33,800 [no audio] 116 00:05:33,800 --> 00:05:37,800 So guys, this is a simple way to define your function, and 117 00:05:37,800 --> 00:05:40,500 is the way how to call or execute your function. 118 00:05:40,700 --> 00:05:45,300 Make sure that your Python function won't execute by itself. 119 00:05:45,300 --> 00:05:48,200 If you want to execute or use your function, you should somewhere 120 00:05:48,200 --> 00:05:49,800 call that function in this way. 121 00:05:50,100 --> 00:05:53,600 So whenever if you are calling your function, your function 122 00:05:53,600 --> 00:05:56,700 name with parenthesis you have to mention. While defining 123 00:05:56,700 --> 00:06:00,100 your function with the 'def', function name, parentheses, ':'. 124 00:06:00,100 --> 00:06:03,500 Under function name with some indentation, with some space 125 00:06:03,500 --> 00:06:05,400 you have to mention some number of lines. 126 00:06:05,600 --> 00:06:06,900 That's it. 127 00:06:08,400 --> 00:06:13,900 Right. Now what I am doing here is, forget about this logic. 128 00:06:15,000 --> 00:06:17,700 See, I am going to define somewhere your function, simply 129 00:06:17,700 --> 00:06:18,700 'display()'. 130 00:06:20,300 --> 00:06:21,300 'print(" 131 00:06:22,600 --> 00:06:25,200 Welcome to functions concept")'. 132 00:06:26,200 --> 00:06:31,600 'print("Simple way to define your function")'. 133 00:06:32,700 --> 00:06:33,800 Right. Let me run it. 134 00:06:34,600 --> 00:06:39,400 No output. No error. No output. So you just defined a function. 135 00:06:40,600 --> 00:06:43,100 So if you want to execute that function, you should call somewhere. 136 00:06:43,800 --> 00:06:45,400 Yes, I'm calling. Now, 137 00:06:45,400 --> 00:06:49,600 it is executing. But instead of calling your function from ninth line 138 00:06:49,700 --> 00:06:51,700 I am going to call it from very first line. 139 00:06:52,900 --> 00:06:55,500 Then see the result what you are getting. You are getting 140 00:06:55,500 --> 00:06:58,500 an error called, name 'display' is not defined. 141 00:06:59,400 --> 00:07:02,800 Why you are getting this error means, see your Python will execute 142 00:07:02,800 --> 00:07:04,200 your code line by line. 143 00:07:04,300 --> 00:07:07,600 It will try to execute first line, as of now 'display'. 144 00:07:07,600 --> 00:07:09,700 [no audio] 145 00:07:09,700 --> 00:07:12,500 As of now your Python don't know what is the 'display'. In case 146 00:07:12,500 --> 00:07:15,800 if it encounters 'def' keyword first, then your Python understands 147 00:07:15,800 --> 00:07:18,800 that 'display' is a function because of this helping keyword. 148 00:07:18,800 --> 00:07:20,600 [no audio] 149 00:07:20,600 --> 00:07:24,700 But you defined somewhere, but before definition defining your 150 00:07:24,700 --> 00:07:28,500 function you are calling, this is not the correct way to define your function. 151 00:07:28,500 --> 00:07:32,700 So always you should define your function first, and after 152 00:07:32,700 --> 00:07:36,000 defining your function you have to call your function. 153 00:07:36,500 --> 00:07:39,700 So before calling your function, somewhere you should define 154 00:07:39,700 --> 00:07:41,600 your function in your sequence. 155 00:07:41,600 --> 00:07:44,300 [no audio] 156 00:07:44,300 --> 00:07:48,900 Fine, and it is a better practice to write at the end 157 00:07:48,900 --> 00:07:52,300 'return None' as of now. As of now, 'return None'. 158 00:07:53,600 --> 00:07:54,700 See, let me run it. 159 00:07:54,800 --> 00:07:56,500 Is there any problem? No problem. 160 00:07:56,600 --> 00:07:59,500 It is working fine. Even though if you include 'return None', 161 00:07:59,500 --> 00:08:00,400 it's working fine. 162 00:08:00,800 --> 00:08:03,500 So actually it is a good practice to write at the end of 163 00:08:03,500 --> 00:08:05,100 your function 'return None'. 164 00:08:06,000 --> 00:08:08,500 So what is the use of that, we'll discuss while going forward. 165 00:08:09,500 --> 00:08:13,700 Right. Fine. And guys, one more thing, while defining your 166 00:08:13,700 --> 00:08:15,900 function name you have to follow some rules. 167 00:08:15,900 --> 00:08:18,200 [no audio] 168 00:08:18,200 --> 00:08:24,400 Rules to define function name. So already we know that guys. 169 00:08:24,400 --> 00:08:26,700 If you remember, what are the rules to define variables. 170 00:08:26,700 --> 00:08:28,600 [no audio] 171 00:08:28,600 --> 00:08:36,900 Variable name should have only 'a' to 'z', or capital 'A' to 'Z', then 172 00:08:36,900 --> 00:08:42,100 number 0 to 9, and then underscore. Only these three group 173 00:08:42,100 --> 00:08:43,100 of characters 174 00:08:43,100 --> 00:08:47,700 you should have in a variable name. Now even function also same thing. 175 00:08:51,000 --> 00:08:54,600 There is no difference. The same rules which we have to define 176 00:08:54,600 --> 00:08:58,100 a variable, all rules are applicable to define your function. 177 00:08:58,100 --> 00:09:00,100 [no audio] 178 00:09:00,100 --> 00:09:03,900 That's it. So capital letters function name and small letters function 179 00:09:03,900 --> 00:09:07,500 names are different, case sensitive, we know that. So just try 180 00:09:07,500 --> 00:09:10,100 to recollect the rules to define variables, 181 00:09:10,600 --> 00:09:14,600 same variable name rules are applicable for your function as well. 182 00:09:15,600 --> 00:09:18,700 Right. You should not start with any number fir your variable. Same here, 183 00:09:18,700 --> 00:09:20,900 also functions should not start with 184 00:09:20,900 --> 00:09:24,700 [no audio] 185 00:09:24,700 --> 00:09:27,400 number, but we can start with 186 00:09:27,400 --> 00:09:30,400 [no audio] 187 00:09:30,400 --> 00:09:33,600 underscore, no problem. Underscore or letters, characters, 188 00:09:34,300 --> 00:09:36,200 and don't include any space. 189 00:09:36,200 --> 00:09:39,900 [no audio] 190 00:09:39,900 --> 00:09:44,400 That's it. So these are the rules. Exactly the variable rules are applicable 191 00:09:44,400 --> 00:09:46,900 even while defining your function name as well. 192 00:09:48,300 --> 00:09:49,300 That's it. 193 00:09:50,100 --> 00:09:51,100 and finally, 194 00:09:51,100 --> 00:09:53,800 [no audio] 195 00:09:53,800 --> 00:09:56,400 so your function must be defined. 196 00:09:56,400 --> 00:09:59,300 [no audio] 197 00:09:59,300 --> 00:10:01,700 before calling it. 198 00:10:02,700 --> 00:10:05,200 See, I am defining at very first your function. 199 00:10:05,200 --> 00:10:06,300 I am calling at sixth line, 200 00:10:06,300 --> 00:10:07,300 then there is no problem. 201 00:10:07,900 --> 00:10:11,300 But if I call our function at very first line, and if I define 202 00:10:11,300 --> 00:10:15,400 this function somewhere in 10th or 11th somewhere below 203 00:10:15,400 --> 00:10:17,400 that then it will create a problem. 204 00:10:17,600 --> 00:10:20,200 It will give an error. That is not the correct 205 00:10:20,200 --> 00:10:23,200 way. First define your function, then somewhere you can 206 00:10:23,200 --> 00:10:24,800 call that. Right. 207 00:10:24,900 --> 00:10:28,500 So guys, once again this is a calling function, and you are calling 208 00:10:28,500 --> 00:10:32,100 this. This is a called function. Called function you're calling 209 00:10:32,100 --> 00:10:37,200 from here. So of course both are same but because of this you 210 00:10:37,200 --> 00:10:38,700 are able to execute these lines. 211 00:10:38,800 --> 00:10:41,300 So this is calling, this is called function. 212 00:10:41,800 --> 00:10:44,900 You need to remember these names as well. And you can call 213 00:10:44,900 --> 00:10:49,500 your function any number of times in your code. Right. Fine. 214 00:10:50,200 --> 00:10:52,700 So finally I want to give this definition 215 00:10:52,700 --> 00:10:56,500 once again. A function is a block of code for some specific 216 00:10:56,500 --> 00:11:00,700 operation, and functions are reusable. 217 00:11:00,800 --> 00:11:04,500 You can reuse your function code any number of times in your 218 00:11:04,700 --> 00:11:08,000 logic. There is no restriction for that. 219 00:11:08,700 --> 00:11:13,000 We can use that any number of times. And one more thing, 220 00:11:13,100 --> 00:11:15,500 it won't execute itself. 221 00:11:15,500 --> 00:11:20,200 It will execute only when it is called in this way. You're 222 00:11:20,200 --> 00:11:22,300 calling from here. This function we called. 223 00:11:22,700 --> 00:11:25,200 So if you don't have this thing, it won't execute, right? 224 00:11:25,300 --> 00:11:27,700 See, let me save it and run it. You don't have any output. 225 00:11:29,000 --> 00:11:32,800 But if I do, if I call that in this way then only it is going 226 00:11:32,800 --> 00:11:34,100 to execute these two lines. 227 00:11:34,100 --> 00:11:36,700 [no audio] 228 00:11:36,700 --> 00:11:41,000 That's it. So guys now tell me why we need functions? Why functions are 229 00:11:41,000 --> 00:11:45,000 required? Why functions are used in our code? First thing 230 00:11:45,000 --> 00:11:47,500 is code reusability purpose. 231 00:11:48,400 --> 00:11:50,600 So we started our introduction of functions with 232 00:11:50,600 --> 00:11:53,000 this concept only. Whenever if you are repeating your logic 233 00:11:53,000 --> 00:11:56,600 in different places, so instead of repeating your logic, 234 00:11:57,100 --> 00:12:00,600 we are writing your logic in one place and we are calling 235 00:12:00,600 --> 00:12:02,400 that in different places. 236 00:12:03,800 --> 00:12:08,000 Then second one, is improve modularity. Means, 237 00:12:08,000 --> 00:12:10,200 [no audio] 238 00:12:10,200 --> 00:12:13,900 see even though if you don't have any requirement with your 239 00:12:13,900 --> 00:12:17,500 functions in your code, it's better to write your code in 240 00:12:17,500 --> 00:12:18,500 terms of functions. 241 00:12:19,300 --> 00:12:24,600 Why? Why means, just assume that you are writing some thousands of lines. 242 00:12:24,600 --> 00:12:26,600 [no audio] 243 00:12:26,600 --> 00:12:28,100 Thousand lines of code you're writing. 244 00:12:29,600 --> 00:12:31,600 So if you don't have functions concept, what you will 245 00:12:31,600 --> 00:12:33,600 do? Line-by-line you will go and write. 246 00:12:34,900 --> 00:12:37,200 Assume that these first four lines are for some specific 247 00:12:37,200 --> 00:12:40,400 purpose, and next hundred lines are for some specific purpose. 248 00:12:40,400 --> 00:12:42,500 [no audio] 249 00:12:42,500 --> 00:12:46,500 Now instead of writing straightforward, if I use some name for this, 250 00:12:46,500 --> 00:12:48,300 [no audio] 251 00:12:48,300 --> 00:12:51,700 right, if I give some name for your different lines, what 252 00:12:51,700 --> 00:12:55,400 is the purpose of that logic? In future easily 253 00:12:55,400 --> 00:12:56,400 I can understand 254 00:12:56,900 --> 00:13:01,300 what is the logic you've written, or the big code 255 00:13:01,300 --> 00:13:04,000 I can split into some parts and each part 256 00:13:04,000 --> 00:13:06,500 I can write as a separate function, and finally I will call 257 00:13:06,500 --> 00:13:08,200 all the functions in one place. 258 00:13:09,500 --> 00:13:13,600 So that the readability will increase by seeing your code, 259 00:13:13,700 --> 00:13:14,700 for your code. 260 00:13:15,800 --> 00:13:20,000 Right. So from now onwards even though if it is having only one 261 00:13:20,000 --> 00:13:23,700 line of code try to write in terms of functions so that you 262 00:13:23,700 --> 00:13:25,800 will be good with functions after sometime. 263 00:13:27,300 --> 00:13:31,000 So from next class onwards, we will try to write each and 264 00:13:31,000 --> 00:13:34,300 every code in terms of functions only, so that you will be 265 00:13:34,300 --> 00:13:36,700 good with functions. Functions are very easy. 266 00:13:36,700 --> 00:13:39,200 You don't need to worry much about your functions. 267 00:13:39,200 --> 00:13:41,100 [no audio] 268 00:13:41,100 --> 00:13:46,100 Right. Then, types of functions. So guys, basically there are two 269 00:13:46,100 --> 00:13:50,100 types of functions. One is built-in functions. Built-in functions 270 00:13:50,100 --> 00:13:51,300 means by default 271 00:13:51,300 --> 00:13:52,700 they are with your Python. 272 00:13:52,700 --> 00:13:55,200 [no audio] 273 00:13:55,200 --> 00:13:59,000 Then user-defined functions, means we are defining those functions. 274 00:13:59,000 --> 00:14:00,200 Just now we defined, right? 275 00:14:00,200 --> 00:14:02,000 We defined one function called 'display'. 276 00:14:02,000 --> 00:14:04,800 [no audio] 277 00:14:04,800 --> 00:14:07,700 So if there is a function, then only you can use it, right? 278 00:14:07,700 --> 00:14:09,300 Let me remove this function. 279 00:14:10,900 --> 00:14:12,900 Right. What I am doing is I am running this. 280 00:14:12,900 --> 00:14:14,800 [no audio] 281 00:14:14,800 --> 00:14:17,400 You're going to get an error called, 'display' is not defined. 282 00:14:17,700 --> 00:14:21,100 Because nowhere we define our function, right. Now, 283 00:14:21,100 --> 00:14:26,600 it is giving perfect output. Same way suppose assume that 284 00:14:26,900 --> 00:14:32,700 I'm writing some 'print(len("hi"))'. 285 00:14:32,700 --> 00:14:35,400 [no audio] 286 00:14:35,400 --> 00:14:37,900 You're getting 2. Actually, 'len()' is a function. 287 00:14:38,500 --> 00:14:41,300 Do you have that in our code? No, but still it is working. 288 00:14:41,800 --> 00:14:44,100 See if I remove this part, 'display' is not working. 289 00:14:44,100 --> 00:14:47,500 Right. If I remove this part 'display' is not working. 290 00:14:47,500 --> 00:14:50,000 [no audio] 291 00:14:50,000 --> 00:14:54,400 But 'len()', nowhere we define 'len()' function, but still 292 00:14:54,400 --> 00:14:55,600 we are able to use that. 293 00:14:56,400 --> 00:14:59,800 So that means this is the default function with your Python, 294 00:15:00,100 --> 00:15:02,200 built-in functions with your Python. 295 00:15:02,700 --> 00:15:04,800 So for built-in functions, you don't need to worry, directly you 296 00:15:04,800 --> 00:15:09,400 can use it. Not only length, if you remember we have suppose, 297 00:15:09,400 --> 00:15:16,200 if I write 'x = 40', then 'print(id(x))', 'id' is also 298 00:15:16,200 --> 00:15:19,000 one built-in function with your Python. It is going to give 299 00:15:19,000 --> 00:15:25,100 you the address of your variable. Not only that, let me take 300 00:15:25,100 --> 00:15:27,800 [no audio] 301 00:15:27,800 --> 00:15:28,800 'x = ' 302 00:15:28,800 --> 00:15:31,400 [no audio] 303 00:15:31,400 --> 00:15:32,400 (5,6), 304 00:15:32,400 --> 00:15:35,700 [no audio] 305 00:15:35,700 --> 00:15:39,400 right. Then 'print(len(x))'. 306 00:15:39,600 --> 00:15:41,800 Now tuple length, you're going to get. 'len()' is already 307 00:15:41,800 --> 00:15:45,900 defined. Not only this we have so many functions 308 00:15:45,900 --> 00:15:50,900 we've already seen. Let's say. 'print(min(x))'. 309 00:15:51,700 --> 00:15:58,300 What is the result? 5. 'min()' is a function here. 'print(max(x))'. 310 00:15:58,300 --> 00:16:02,800 Maximum value among your values in 'x', 6. So these all 311 00:16:02,800 --> 00:16:06,100 are some of the default functions with your Python. 312 00:16:06,100 --> 00:16:08,100 [no audio] 313 00:16:08,100 --> 00:16:09,900 Not only that, 'int(x)', right. 314 00:16:09,900 --> 00:16:12,600 I mean if you want to do some type conversion what you are 315 00:16:12,600 --> 00:16:17,400 doing? 'int', 'list', conversion, right. Suppose if I have a 316 00:16:18,900 --> 00:16:21,200 '5', that is a string actually. Now, 317 00:16:21,200 --> 00:16:25,000 what I am doing is, I am trying to convert that as a integer. 318 00:16:25,100 --> 00:16:30,200 So 'int(x)', 'int()' is a function here, but that is 319 00:16:30,200 --> 00:16:33,700 a built-in function or default function with your Python. 320 00:16:33,700 --> 00:16:36,200 [no audio] 321 00:16:36,200 --> 00:16:42,400 Right. So you have two types of functions - one is user defined 322 00:16:42,400 --> 00:16:44,700 functions, and one more is built-in functions. 323 00:16:45,200 --> 00:16:49,200 So very rarely we used built-in functions. 324 00:16:49,200 --> 00:16:52,200 But sometimes you have very importance with your built-in 325 00:16:52,200 --> 00:16:56,000 functions, with some functions, some built-in functions, 326 00:16:56,000 --> 00:16:58,600 but most of the cases you are going to define your user defined 327 00:16:58,600 --> 00:17:01,700 functions. Right. 328 00:17:01,900 --> 00:17:07,098 So now your concentration is how to define and use and work 329 00:17:07,098 --> 00:17:09,200 with your user-defined functions. 330 00:17:09,200 --> 00:17:11,200 [no audio] 331 00:17:11,200 --> 00:17:15,400 Right. So as of now we have seen simple way to define your function, 332 00:17:16,400 --> 00:17:17,400 right. In next video 333 00:17:17,400 --> 00:17:21,400 we will see in detail with your functions, how to define, and 334 00:17:21,400 --> 00:17:25,700 how to call with some arguments. See 'display' in parentheses 335 00:17:25,700 --> 00:17:28,900 I'm not writing anything, but in 'len()', I am writing something. 336 00:17:29,300 --> 00:17:30,599 So why should we write this? 337 00:17:31,099 --> 00:17:34,800 So to understand this function you need to work with your 338 00:17:35,400 --> 00:17:39,099 user defined functions by passing some value here so that 339 00:17:39,099 --> 00:17:42,200 you can understand effectively why 'len()' requires some input. 340 00:17:43,700 --> 00:17:44,700 Right. 341 00:17:45,599 --> 00:17:48,599 Okay guys, so finally you need to remember this, how to define 342 00:17:48,599 --> 00:17:52,599 a function and how to call a function. Right. 343 00:17:53,800 --> 00:17:56,000 Okay guys, thank you for watching this video. 344 00:17:56,000 --> 00:18:03,200 [no audio]