1 00:00:11,440 --> 00:00:13,120 Hello, my precious students. 2 00:00:13,300 --> 00:00:19,600 And in this lecture, we will see some live, quote, examples regarding methods we we have learned 3 00:00:19,600 --> 00:00:26,200 in the previous video what our methods, methods, BASIX basically, and we have seen method that does 4 00:00:26,200 --> 00:00:27,460 not receive a very well. 5 00:00:27,460 --> 00:00:32,420 And we have also seen an example of a method that does receive a variable. 6 00:00:32,800 --> 00:00:34,390 So let's see some examples. 7 00:00:34,580 --> 00:00:37,480 And once you open your project, create methods. 8 00:00:39,680 --> 00:00:42,160 Live examples file. 9 00:00:42,530 --> 00:00:43,130 All right. 10 00:00:44,780 --> 00:00:46,100 And here also. 11 00:00:48,530 --> 00:00:56,120 And right here, I just want to create a quick method, if you remember, there was a special special 12 00:00:56,120 --> 00:01:03,800 word, special word key that indicates that we're dealing with a method and that word is def. 13 00:01:04,140 --> 00:01:04,550 Right. 14 00:01:05,660 --> 00:01:13,790 And then just create a new new method and you could call a salary salary calculation. 15 00:01:14,870 --> 00:01:22,490 Just want to pay to get your intention to the following thing or in the beginning of the course, I 16 00:01:22,490 --> 00:01:29,000 mentioned that we're going to discuss and we're going to focus on coding conventions. 17 00:01:29,210 --> 00:01:35,360 Coding conventions is basically some agreed rules between all developers, and there are rules for each 18 00:01:35,360 --> 00:01:39,750 each programming language separately. 19 00:01:40,130 --> 00:01:48,710 So in Python, we also have coding conventions, meaning some accepted rules among developers worldwide, 20 00:01:49,370 --> 00:01:53,860 which are dictated by the company that invented Python, basically. 21 00:01:53,870 --> 00:01:58,130 So it's not that every person can invent its own his own rules. 22 00:01:58,580 --> 00:02:06,530 So the conventions regarding variables we we have already discussed and basically these rules apply 23 00:02:06,530 --> 00:02:08,870 upon methods as well. 24 00:02:08,870 --> 00:02:16,550 So basically methods and variables have the same rules regarding coding conventions, coding conventions. 25 00:02:16,590 --> 00:02:19,430 Basically, what is 26 00:02:21,830 --> 00:02:26,120 relevant to this point is the naming of the naming. 27 00:02:26,420 --> 00:02:31,300 This is like the big name of coding conventions goes down to the naming. 28 00:02:31,480 --> 00:02:39,170 OK, so at this point, if you create methods so first of all, start the name of the method with small 29 00:02:39,170 --> 00:02:43,220 letters and if you have more than one word in the naming. 30 00:02:43,490 --> 00:02:46,480 So just separate them with another score. 31 00:02:47,210 --> 00:02:53,500 So it's a very important rule to keep in order to stay professional and not to make fool of ourselves, 32 00:02:53,510 --> 00:02:56,750 of ourselves once you get to job interviews and so on. 33 00:02:57,380 --> 00:02:57,790 All right. 34 00:02:57,800 --> 00:03:01,280 So this is our method called salary calculations. 35 00:03:01,280 --> 00:03:14,390 And in here, I'm going to do a salary of the employee and it will be consist of salary variable multiplied 36 00:03:14,390 --> 00:03:15,740 by 098. 37 00:03:16,700 --> 00:03:24,170 Basically I reducing if I'm getting some kind of salary, I'm reducing two percent out of the whole 38 00:03:24,170 --> 00:03:24,740 salary. 39 00:03:24,980 --> 00:03:33,480 Once I multiplied in zero dark 98 and you can address this number as taxes for example. 40 00:03:34,160 --> 00:03:34,540 All right. 41 00:03:34,790 --> 00:03:37,820 It doesn't really have any meaning just for the practice. 42 00:03:37,850 --> 00:03:38,200 All right. 43 00:03:38,600 --> 00:03:45,110 So you can see right here we have the calculation and at the end, I just want to print it. 44 00:03:45,110 --> 00:03:47,990 And the salary is. 45 00:03:51,060 --> 00:03:59,540 Is the salary of the employee all right, so this is our method, OK, right here and this is our methods 46 00:03:59,540 --> 00:04:00,260 content. 47 00:04:00,540 --> 00:04:04,880 And basically we're missing one thing, which is this variable salary. 48 00:04:05,180 --> 00:04:14,330 And as we've seen in the previous lecture, we first to in order for this method to be called or executed, 49 00:04:14,510 --> 00:04:17,920 we need we need to execute it outside of the method itself. 50 00:04:18,140 --> 00:04:24,140 So as long as they have intention, as long as I have like spaces here inside the method and right now 51 00:04:24,140 --> 00:04:29,970 I'm going to press back but make space and now again at the beginning of the line here. 52 00:04:29,990 --> 00:04:32,930 So that means that I'm outside of the method content. 53 00:04:32,930 --> 00:04:34,820 I'm outside of this whole method thing. 54 00:04:35,180 --> 00:04:37,940 And right now I'm just going to execute it. 55 00:04:37,940 --> 00:04:46,070 And how they do it, basically, I just mention the method and also I want to pass some variable into 56 00:04:46,070 --> 00:04:46,220 it. 57 00:04:46,230 --> 00:04:48,650 I want to pass a salary variable. 58 00:04:49,040 --> 00:04:58,430 And as you as you can guess, it's not a string variable because I'm not going to multiply a word upon 59 00:04:58,550 --> 00:04:59,220 a number. 60 00:04:59,240 --> 00:05:00,170 It's not logical. 61 00:05:00,410 --> 00:05:03,680 So obviously, this number should be in some kind of number. 62 00:05:03,800 --> 00:05:05,380 And I want to pass it from here. 63 00:05:05,420 --> 00:05:12,980 This is point A and this is going to be point B and this is going to be point C, so you can check out 64 00:05:12,980 --> 00:05:13,970 the previous lecture. 65 00:05:14,150 --> 00:05:22,520 I discussed it in the last part there, that once we put the variable over here in the in the execution 66 00:05:22,520 --> 00:05:26,150 part, this is the first point which the variable is inserted. 67 00:05:26,360 --> 00:05:32,670 Then it goes up to the top to the methods declaration and from there it goes inside the method itself. 68 00:05:32,930 --> 00:05:38,030 So if a board, for example, 1000 or maybe 10000 like this. 69 00:05:39,060 --> 00:05:39,520 All right. 70 00:05:39,890 --> 00:05:42,230 So right here it's back. 71 00:05:42,380 --> 00:05:47,390 It has good brownish background because it's unexpected. 72 00:05:47,660 --> 00:05:48,980 And why is it unexpected? 73 00:05:48,980 --> 00:05:50,900 Because I didn't put it over here as well. 74 00:05:51,140 --> 00:05:57,650 And here in the math, a declaration declaration of the variable should be the same, as I mentioned 75 00:05:57,650 --> 00:06:03,440 it inside the method candidate content because they need to identify one another. 76 00:06:03,500 --> 00:06:06,600 OK, so I'm just going to put salary here as well. 77 00:06:08,300 --> 00:06:08,750 All right. 78 00:06:09,050 --> 00:06:10,100 And now we're good. 79 00:06:10,340 --> 00:06:17,780 OK, so I've sat here 10000 thousand then I'm just executing this method, meaning this one. 80 00:06:18,710 --> 00:06:20,560 And I've said ten thousand here. 81 00:06:20,720 --> 00:06:26,170 So basically here it's going to be equals to ten thousand at this point. 82 00:06:27,020 --> 00:06:34,700 This does American here ABCDs as long as here inside, they also are going to have the same thing. 83 00:06:34,730 --> 00:06:36,280 OK, then it's correct. 84 00:06:36,340 --> 00:06:41,480 It doesn't matter what I put here, as long as it's the same thing that I have inside the methods content. 85 00:06:42,680 --> 00:06:43,000 Right. 86 00:06:43,370 --> 00:06:45,490 So I'm just going to put something meaningful here. 87 00:06:45,800 --> 00:06:50,270 Also, this is one of the parts that our convention is very important. 88 00:06:50,420 --> 00:06:56,330 Just to say, just to state your full names for variables. 89 00:06:56,840 --> 00:07:03,080 I've seen lots of unexperienced programmers that put variables such as this cell, meaning it's short 90 00:07:03,080 --> 00:07:11,240 of salary, but this is no good because I know if I wrote it, I know this the short of salary, what 91 00:07:11,240 --> 00:07:16,130 someone else can come tomorrow on the on for for a year from now and read it. 92 00:07:16,130 --> 00:07:18,650 And he will not understand what what he says. 93 00:07:19,100 --> 00:07:19,480 All right. 94 00:07:19,520 --> 00:07:26,810 He will not understand maybe from this reference right here, he can understand a salary ESL stance 95 00:07:26,810 --> 00:07:33,240 for salary, but doesn't matter just you want to make easy life for your co-workers that work with you. 96 00:07:33,260 --> 00:07:41,870 OK, so one of the main rules of professional programming is to put full names and not short names for 97 00:07:41,870 --> 00:07:42,520 variables. 98 00:07:42,530 --> 00:07:42,920 All right. 99 00:07:44,570 --> 00:07:45,170 Like this. 100 00:07:46,910 --> 00:07:50,020 So let's run this for for a second and see what we have. 101 00:07:50,330 --> 00:07:50,660 All right. 102 00:07:50,660 --> 00:07:56,660 So the salary is ninety eight hundred, as we expected from this print right here. 103 00:07:56,960 --> 00:08:04,760 But look at this line if I want to put some other number here, OK, so I don't need to create an additional 104 00:08:04,760 --> 00:08:08,090 method, OK, because this is just a variable. 105 00:08:08,960 --> 00:08:09,950 This is a variable. 106 00:08:10,220 --> 00:08:20,450 I can I can execute this method again with a different variable so I can make a separate line, remove 107 00:08:20,450 --> 00:08:21,590 the brackets here. 108 00:08:21,980 --> 00:08:25,820 I can create a separate line and put 5000 here. 109 00:08:26,180 --> 00:08:28,040 OK, you see the beauty of it. 110 00:08:28,430 --> 00:08:32,120 So I'm using this bulk of code as many times as I want in the code. 111 00:08:32,450 --> 00:08:37,850 Just created it once and then I can execute it how many times I want. 112 00:08:37,850 --> 00:08:38,780 Let's run it again. 113 00:08:40,900 --> 00:08:46,540 You see the printout here, so I used it twice and I can use it a million times from now and I don't 114 00:08:46,540 --> 00:08:48,520 need to create the calculation. 115 00:08:49,540 --> 00:08:54,580 This part again and again for each variable that I've set here, don't need to do it. 116 00:08:54,700 --> 00:08:55,600 Just do it once. 117 00:08:55,600 --> 00:08:56,240 And that's it. 118 00:08:56,530 --> 00:08:56,930 All right. 119 00:08:57,550 --> 00:09:03,830 So this is the whole idea of this method, method, trick. 120 00:09:04,180 --> 00:09:07,240 This is very important for object oriented programming. 121 00:09:07,420 --> 00:09:08,890 Our next topic. 122 00:09:09,100 --> 00:09:16,990 So it's a very useful and very meaningful part in programming in general. 123 00:09:17,020 --> 00:09:17,410 All right. 124 00:09:18,200 --> 00:09:22,640 I also just want to show you a new trick that we haven't started yet. 125 00:09:22,900 --> 00:09:24,900 We can put several variables here. 126 00:09:25,090 --> 00:09:36,970 So if I put, for example, the multiplication number or maybe like tax reduction. 127 00:09:37,600 --> 00:09:47,710 OK, so I could put two variables here inside the method declaration as long as I put here also two 128 00:09:47,710 --> 00:09:48,610 numbers as well. 129 00:09:48,860 --> 00:09:52,360 And then just I'm going to remove this one. 130 00:09:52,920 --> 00:09:57,060 OK, ok then 098 just put two variables here. 131 00:09:57,730 --> 00:10:01,660 OK, then he asks me to put two as well and these two as well. 132 00:10:01,960 --> 00:10:06,670 You see, you see here when a hover parameter tax reduction on field. 133 00:10:06,670 --> 00:10:15,040 So it demands me to put it demands me to put two variables and now it's more dynamic because now I can 134 00:10:15,040 --> 00:10:20,590 put one time the tax reduction to be 098 in a different time. 135 00:10:20,600 --> 00:10:21,130 For example. 136 00:10:21,130 --> 00:10:22,960 It's a different country. 137 00:10:22,960 --> 00:10:25,120 I can put different tax. 138 00:10:25,300 --> 00:10:30,230 So it's very flexible and you see the beauty of it because you can put you whatever you want. 139 00:10:30,610 --> 00:10:40,330 So once I have here 098 this called hardcoded, this is the term hardcoded variable hardcoded means 140 00:10:40,480 --> 00:10:41,460 that you can't change it. 141 00:10:41,560 --> 00:10:43,000 It stays still forever. 142 00:10:43,000 --> 00:10:45,450 The same number, but now it's not hardcoded. 143 00:10:45,460 --> 00:10:47,620 Now it's advanced and it's dynamic. 144 00:10:47,860 --> 00:10:56,590 OK, so each time I owe, each time I execute this method, I can put different variables for tax reduction 145 00:10:56,590 --> 00:10:58,180 and different variables for salary. 146 00:10:58,960 --> 00:11:00,010 Let's see how it goes. 147 00:11:00,400 --> 00:11:01,150 Let's run it. 148 00:11:02,440 --> 00:11:04,120 OK, we have some kind of problem here. 149 00:11:04,120 --> 00:11:05,650 Of course, I don't have a comma. 150 00:11:08,470 --> 00:11:10,210 All right, OK. 151 00:11:10,280 --> 00:11:16,400 So everything's fine, so we put the celery here and we put the tax reduction over here. 152 00:11:16,420 --> 00:11:16,890 Great. 153 00:11:17,290 --> 00:11:20,500 So this summer's off the basic part of math. 154 00:11:20,770 --> 00:11:21,970 You can see it's very simple. 155 00:11:21,970 --> 00:11:28,690 You can put one variable here or even two variables here as long as you put also two variables in the 156 00:11:28,690 --> 00:11:29,890 execution line. 157 00:11:30,070 --> 00:11:36,070 And also it can execute it as many times as you want, each time with different variables inside the 158 00:11:36,070 --> 00:11:36,580 method. 159 00:11:36,730 --> 00:11:40,400 So it's a very flexible and you can see why it's very important in programming. 160 00:11:41,290 --> 00:11:41,830 All right. 161 00:11:42,040 --> 00:11:44,720 That sums up this lecture I will see in the next one. 162 00:11:44,740 --> 00:11:45,210 Thank you. 163 00:11:45,210 --> 00:11:45,820 Wemba by.