1 00:00:11,730 --> 00:00:17,850 Hi, everybody, and welcome, I'm very happy to provide you with this lecture, and today we will see 2 00:00:17,850 --> 00:00:23,420 an additional example in life cording off object oriented programming in Python. 3 00:00:23,670 --> 00:00:31,560 We're going to create a class, the init method, some methods that are off the object and also to create 4 00:00:31,560 --> 00:00:32,760 the instance of an object. 5 00:00:32,760 --> 00:00:35,640 And all of this is going to be in this lecture life. 6 00:00:35,650 --> 00:00:36,020 All right. 7 00:00:36,390 --> 00:00:39,910 So once you were in your pichon, just create a new file and let's begin. 8 00:00:40,290 --> 00:00:46,820 So today we're going to discuss Rentoul program of attendance. 9 00:00:47,010 --> 00:00:49,080 And this is what you were going to do. 10 00:00:49,080 --> 00:00:49,460 All right. 11 00:00:49,620 --> 00:00:52,860 In this lecture, I really recommend you just to listen. 12 00:00:53,130 --> 00:01:00,730 And I'm also going to provide you the Python file that you can later on import into your pie chart or 13 00:01:00,730 --> 00:01:03,210 even copy paste it into your own pie chart. 14 00:01:03,930 --> 00:01:06,210 And that way you could just do experiments on it. 15 00:01:06,330 --> 00:01:10,830 But this is very important for you to listen and to understand all the terms and all the logics that 16 00:01:10,830 --> 00:01:16,980 I'm going to explain basically is going to be live coding example, same as we did in the previous lecture, 17 00:01:16,980 --> 00:01:18,540 but with a different example. 18 00:01:18,570 --> 00:01:18,920 All right. 19 00:01:18,930 --> 00:01:19,890 So let's begin. 20 00:01:20,310 --> 00:01:25,980 So as we were discussing a rental program, let's create a new class and you can call it building. 21 00:01:26,590 --> 00:01:27,090 All right. 22 00:01:27,200 --> 00:01:29,130 I just want you to notice something. 23 00:01:29,370 --> 00:01:31,910 If I put a small letter B here. 24 00:01:32,250 --> 00:01:32,730 All right. 25 00:01:33,960 --> 00:01:40,620 So you can see here that if I'm hovering, you can see class names should use Kemakeza Convention. 26 00:01:40,740 --> 00:01:45,750 So even pie chart tells us, please, dear developer, keep the conventions right. 27 00:01:45,780 --> 00:01:48,750 OK, so we need to put capital letter. 28 00:01:48,770 --> 00:01:53,630 We discussed it in the first lecture or the second of OLP in discourse. 29 00:01:53,850 --> 00:02:00,320 So after we created the class, let's start off and build our object. 30 00:02:00,330 --> 00:02:00,580 All right. 31 00:02:00,870 --> 00:02:05,910 So first one would be inside the class would be the Init method. 32 00:02:06,120 --> 00:02:14,400 OK, you need to put underscores here and then you have here are the variables that you're going to 33 00:02:14,400 --> 00:02:16,890 pass through the object. 34 00:02:17,160 --> 00:02:23,550 By the way, if you put one underscore here, it's no good to put double R discourse in each side and 35 00:02:23,550 --> 00:02:25,050 then it changes its color. 36 00:02:25,110 --> 00:02:29,410 And afterwards you have to add the self key, key word right here. 37 00:02:29,910 --> 00:02:37,680 So the variables that I'm going to use today is use a season in year apartment. 38 00:02:40,030 --> 00:02:42,610 No, an apartment size. 39 00:02:42,730 --> 00:02:43,120 All right. 40 00:02:43,420 --> 00:02:45,460 These are the three variables that I'm going to use. 41 00:02:46,180 --> 00:02:52,530 And inside the Æneas method, we're going to use the properties of the object using the South barometer. 42 00:02:52,540 --> 00:02:57,580 So we put myself at the moment, I'm just going to copy paste it. 43 00:02:57,610 --> 00:02:58,000 All right. 44 00:02:58,870 --> 00:02:59,770 By the way, it's. 45 00:03:01,580 --> 00:03:03,500 Like this and. 46 00:03:05,980 --> 00:03:11,740 Like this, sometimes I'm typing very fast and don't know this, all right, so I'm just going to copy 47 00:03:11,740 --> 00:03:13,100 paste it with my keyboard. 48 00:03:13,130 --> 00:03:13,480 All right. 49 00:03:15,310 --> 00:03:19,360 Just to save time, because I don't want to waste your time on not important things. 50 00:03:19,360 --> 00:03:23,530 I want you to focus on the important things, which is the logic here as well. 51 00:03:23,530 --> 00:03:26,470 S self that then the second variable. 52 00:03:27,710 --> 00:03:30,940 OK, and then the third one self. 53 00:03:31,720 --> 00:03:35,050 That apartment size equals apartment size. 54 00:03:35,500 --> 00:03:38,080 So our init method is ready. 55 00:03:38,320 --> 00:03:38,860 All right. 56 00:03:42,490 --> 00:03:48,040 And I mentioned that this would be a lecture and an object regarding a rental. 57 00:03:48,070 --> 00:03:48,390 All right. 58 00:03:48,610 --> 00:03:52,100 So we're going to create the methods of an object right here. 59 00:03:52,120 --> 00:03:52,680 Two of them. 60 00:03:52,690 --> 00:03:55,600 First one is rental calculation. 61 00:03:55,780 --> 00:03:56,400 All right. 62 00:03:56,710 --> 00:04:02,920 And by the way, once I type it out calculation, I put the first bracket boom, the self parameter 63 00:04:03,100 --> 00:04:05,110 is automatically completed. 64 00:04:05,290 --> 00:04:06,580 I'm going to leave it empty. 65 00:04:06,580 --> 00:04:06,950 For what? 66 00:04:06,980 --> 00:04:07,530 For now. 67 00:04:07,660 --> 00:04:09,940 And the second method would be monthly. 68 00:04:13,080 --> 00:04:13,950 Maintenance 69 00:04:16,440 --> 00:04:17,700 bay, all right. 70 00:04:19,560 --> 00:04:22,530 I didn't put them here, so there was no outdoor comp.. 71 00:04:22,530 --> 00:04:24,840 Yeah, like this and then self over here. 72 00:04:25,680 --> 00:04:26,310 All right. 73 00:04:29,580 --> 00:04:31,260 So now we have two methods here. 74 00:04:32,400 --> 00:04:37,310 These are methods of an object and we have air here because we didn't put the bass. 75 00:04:38,220 --> 00:04:38,590 Yeah. 76 00:04:38,840 --> 00:04:42,110 Now, just put in putting the bass here for now. 77 00:04:42,120 --> 00:04:47,620 We're going to fill it with some manipulations on these variables in a bit. 78 00:04:47,640 --> 00:04:48,060 All right. 79 00:04:49,140 --> 00:04:56,940 And the additional thing that I want to do right now is just basically before I'm going to do a lot 80 00:04:56,940 --> 00:04:58,890 of mess here and do some calculations. 81 00:04:58,890 --> 00:05:04,500 And you say these methods are just going to create two instances of an object, and I will call them 82 00:05:04,500 --> 00:05:07,200 lease contract one. 83 00:05:08,760 --> 00:05:12,840 And then we're going to place the name of the class, as always. 84 00:05:12,990 --> 00:05:19,800 And inside the brackets, I'm going to put a values for these three variables, which will become these 85 00:05:19,800 --> 00:05:23,490 three parameters of an instance. 86 00:05:23,520 --> 00:05:23,910 All right. 87 00:05:25,170 --> 00:05:27,420 So first one is season of the year. 88 00:05:27,570 --> 00:05:32,820 I'm going to put some are here, OK? 89 00:05:32,940 --> 00:05:34,410 Summer is a great season. 90 00:05:34,680 --> 00:05:39,690 And second one would be apartment number four, for example, and apartment size. 91 00:05:39,720 --> 00:05:41,670 One hundred and thirty five meters. 92 00:05:41,940 --> 00:05:44,340 And let's create an additional one. 93 00:05:44,550 --> 00:05:47,100 Going to copy it and place it here. 94 00:05:48,060 --> 00:05:49,160 At least contract you. 95 00:05:49,560 --> 00:05:51,000 Then we have spring. 96 00:05:51,990 --> 00:05:58,050 OK, and then apartment number six and apartment size would be one hundred meters. 97 00:05:58,550 --> 00:06:06,570 OK, so we had these three instances of an object and right now basically these three variables are 98 00:06:06,570 --> 00:06:09,810 accepted in these three up and here inside the unit method. 99 00:06:10,840 --> 00:06:16,380 And then these three are our best into these three parameters. 100 00:06:16,430 --> 00:06:21,530 OK, and then we have the self key world inside each of these methods. 101 00:06:21,540 --> 00:06:27,310 So basically we can use any of these parameters, any of these properties inside these methods. 102 00:06:27,330 --> 00:06:28,920 OK, we can do manipulations on them. 103 00:06:28,920 --> 00:06:30,600 We can print them whatever we want. 104 00:06:30,960 --> 00:06:31,410 All right. 105 00:06:31,620 --> 00:06:38,280 So this is this self worth is a connector that basically says all the all the parameters that you have 106 00:06:38,280 --> 00:06:40,450 in here, you can use them inside this method. 107 00:06:40,500 --> 00:06:42,680 This is what the self key word means. 108 00:06:42,690 --> 00:06:43,000 All right. 109 00:06:43,320 --> 00:06:49,050 So, first of all, let's discuss we're going to focus in the next few minutes only in this method. 110 00:06:49,200 --> 00:06:52,480 And I'm going to put some calculations here depending on the variables. 111 00:06:52,500 --> 00:06:52,800 All right. 112 00:06:53,100 --> 00:06:56,380 So we're going to do the following thing and we're going to create two variables. 113 00:06:56,400 --> 00:07:02,460 First one is base price per month equals two thousand. 114 00:07:02,670 --> 00:07:10,650 And we're going to do season price buffer, which the default value would be zero for now. 115 00:07:10,980 --> 00:07:20,490 OK, and then I'm going to put three ifs actually for ifs if self OK, self season of the season in 116 00:07:20,490 --> 00:07:20,920 the year. 117 00:07:21,210 --> 00:07:29,610 OK, so once I put myself that season in the year, whatever is best from here and accept it here and 118 00:07:29,610 --> 00:07:33,660 then went up in here, ok, we can use it inside this method. 119 00:07:33,660 --> 00:07:37,830 OK, and once we have created two instances. 120 00:07:37,860 --> 00:07:42,510 OK, so for each of them the values are going to be different. 121 00:07:42,510 --> 00:07:45,420 For the first one the summer would be accepted. 122 00:07:45,660 --> 00:07:47,820 OK, and for the second one would be spring. 123 00:07:48,220 --> 00:07:56,490 OK, so if season in, in the year would be summer, I want the season parameter 124 00:07:59,520 --> 00:08:00,680 season price by far. 125 00:08:00,690 --> 00:08:01,580 It's not a barometer. 126 00:08:01,600 --> 00:08:02,550 This is simple. 127 00:08:02,550 --> 00:08:04,860 Variable would be one point five. 128 00:08:05,210 --> 00:08:11,610 OK, first of all, I'm referring to this variable and the reason that I don't have self here, OK, 129 00:08:11,790 --> 00:08:15,320 this is the reason I'm not doing this thing. 130 00:08:15,370 --> 00:08:19,680 OK, instance through season, define outside. 131 00:08:19,680 --> 00:08:22,560 In it you see what's happening here. 132 00:08:22,560 --> 00:08:28,330 Once I however this instance attribute season price for define outside in it. 133 00:08:28,350 --> 00:08:35,130 OK, it says to us that we don't have the season price buffer here and that's because we haven't have 134 00:08:35,130 --> 00:08:37,980 him on the inside the method. 135 00:08:38,190 --> 00:08:40,080 So it's not connected. 136 00:08:40,080 --> 00:08:44,700 We don't need to put self here, it's not connected to the self and the reason is because we don't pass 137 00:08:44,700 --> 00:08:45,360 it through here. 138 00:08:46,090 --> 00:08:48,060 It's an internal variable. 139 00:08:48,090 --> 00:08:48,480 OK. 140 00:08:49,830 --> 00:08:57,960 And basically what I want to do is I want to according to the season I'm sorry, according to the season, 141 00:08:58,860 --> 00:09:03,300 I want to change the price, the base price per month value. 142 00:09:03,540 --> 00:09:09,630 Meaning in the summer I'm going to multiply two thousand by one point five because the summer is a very 143 00:09:09,630 --> 00:09:11,790 popular season for. 144 00:09:11,910 --> 00:09:18,930 Car rental, and at the winter, it's less popular, so I'm going to multiply, for example, by oh, 145 00:09:19,200 --> 00:09:20,690 by one point one. 146 00:09:20,730 --> 00:09:22,820 So the price, the total price would be less. 147 00:09:22,860 --> 00:09:24,480 OK, you know what I'm saying? 148 00:09:24,720 --> 00:09:32,260 This is what I'm heading to season winter, OK? 149 00:09:32,640 --> 00:09:39,150 At the end, we're going to add a calculation season, but four is one point one. 150 00:09:39,750 --> 00:09:43,830 And then, by the way, it's not supposed to be if it's ayliffe. 151 00:09:43,830 --> 00:09:44,190 Right. 152 00:09:44,610 --> 00:09:47,070 The last one would be else. 153 00:09:47,220 --> 00:09:52,710 And we have an additional Ayliffe sales season and then we have spring. 154 00:09:54,300 --> 00:09:54,720 Yeah. 155 00:09:55,680 --> 00:09:57,930 And spring is a bit popular. 156 00:09:58,140 --> 00:10:08,040 More popular than the winter, but less than the summer, for example, one point four and else season 157 00:10:08,790 --> 00:10:11,880 price four would be one point three. 158 00:10:11,910 --> 00:10:16,940 OK, so we have in total four seasons in the year. 159 00:10:17,160 --> 00:10:20,280 So I've set up three of them here and the fourth one. 160 00:10:20,580 --> 00:10:23,520 OK, so we have summer, winter, spring and autumn. 161 00:10:23,730 --> 00:10:26,150 OK, so the autumn obviously going to go here. 162 00:10:26,160 --> 00:10:32,520 So if none of these were found and in total in human life, we have only four seasons. 163 00:10:32,530 --> 00:10:39,840 So if none of these were accepted, so the difficult one will be autumn or even more. 164 00:10:40,260 --> 00:10:46,420 Even a better idea would be to put autumn here up. 165 00:10:46,680 --> 00:10:50,340 Just going to remove the redundant space. 166 00:10:50,340 --> 00:10:50,730 Yeah. 167 00:10:51,150 --> 00:10:55,340 And put Autumn here. 168 00:10:56,670 --> 00:10:57,150 Yeah. 169 00:11:00,400 --> 00:11:10,180 And then what we're going to do is put like this, yeah, and with indention and then else meaning if 170 00:11:10,180 --> 00:11:15,280 we got something else, we're going to do return or maybe season. 171 00:11:16,810 --> 00:11:18,970 But for none. 172 00:11:19,510 --> 00:11:28,090 OK, so in cases other of these four items, it was received through the instance, we're going to insert 173 00:11:28,090 --> 00:11:29,780 Nunn into the variable. 174 00:11:29,800 --> 00:11:32,170 OK, this is the more correct way to do it. 175 00:11:32,680 --> 00:11:33,100 OK. 176 00:11:33,280 --> 00:11:37,960 And basically what I'm going to do is I'm going to do an additional thing. 177 00:11:38,710 --> 00:11:47,560 Also, I want four apartments that are very large to to enlarge this buffer even more. 178 00:11:47,610 --> 00:11:56,970 OK, meaning if it's summer and if apartment size is above one hundred thirty meters. 179 00:11:57,370 --> 00:12:03,870 So I want the Susan buffer to be plus zero one up. 180 00:12:07,120 --> 00:12:13,990 OK, so let's have a quick example, Summers received went up and here goes to the summersault, the 181 00:12:13,990 --> 00:12:18,250 buffer is one point five going down and then coming to here. 182 00:12:18,520 --> 00:12:25,960 If we find out that the apartment size is above one hundred thirty meters, I'm saying to the program, 183 00:12:25,960 --> 00:12:30,070 you know what, it's one point five, but make it one point six. 184 00:12:30,340 --> 00:12:31,870 OK, because the apartment is large. 185 00:12:31,870 --> 00:12:41,100 So Grothe, the apartment, the apartment before the lease bought for four zero point one some more. 186 00:12:41,140 --> 00:12:50,620 OK, and then I want to do the last calculation here, which will be I'm going to create a new variable. 187 00:12:50,740 --> 00:12:53,370 By the way, this thing is should be less. 188 00:12:53,380 --> 00:12:58,920 You see that I set up the F here as if it was part of the Ellis'. 189 00:12:58,960 --> 00:13:02,420 OK, so you see the indention here and here is the same. 190 00:13:02,620 --> 00:13:08,000 So basically this thing would be executed only if the program would go inside the house. 191 00:13:08,140 --> 00:13:09,040 This is not what I want. 192 00:13:09,040 --> 00:13:14,040 I want this part to be indented, same as the if else, OK? 193 00:13:14,260 --> 00:13:17,830 I don't want it to be executed only if the program goes through. 194 00:13:17,840 --> 00:13:18,610 Also, I don't want it. 195 00:13:18,610 --> 00:13:21,310 So I'm going to do shift Darb. 196 00:13:21,740 --> 00:13:23,540 OK, and now we are OK. 197 00:13:23,710 --> 00:13:30,070 So for example, we're going into the summer, OK, and then we are ignoring all of this going down 198 00:13:30,070 --> 00:13:31,050 and coming through here. 199 00:13:31,360 --> 00:13:36,970 OK, so this if these else ifs are not connected at all. 200 00:13:37,030 --> 00:13:44,290 OK, so now we have our buffer prepared and I want to do a calculation, so I'm going to create a new 201 00:13:44,290 --> 00:13:44,890 variable. 202 00:13:44,890 --> 00:13:47,530 Total rent price. 203 00:13:47,810 --> 00:13:55,150 Yeah, I'm going to take the best price and multiply by season price buffer like this. 204 00:13:55,360 --> 00:14:01,540 OK, so I have here the total price and I want you to I want to teach you something new. 205 00:14:01,930 --> 00:14:10,510 OK, so usually what we're doing is the total the total price is and we're doing plus SDR and total 206 00:14:10,510 --> 00:14:11,410 price like this. 207 00:14:11,860 --> 00:14:19,270 But I want you to learn in more advanced way to print out values and in order you would not need this. 208 00:14:19,510 --> 00:14:20,380 The casting. 209 00:14:20,980 --> 00:14:22,390 This is like beginners way. 210 00:14:22,390 --> 00:14:25,060 I want you to scale up your prints. 211 00:14:25,060 --> 00:14:26,490 So let's do the following thing. 212 00:14:27,580 --> 00:14:30,520 This thing is, is subtopic inside objects. 213 00:14:31,120 --> 00:14:34,740 I'm going to teach you string formatting. 214 00:14:34,750 --> 00:14:43,720 OK, so for a few seconds, we're putting aside all of this object and methods and we are going to teach 215 00:14:43,930 --> 00:14:51,880 this small topic string formatting because we can do the sprint, this print in a more advanced way. 216 00:14:52,610 --> 00:14:53,650 And this is the following way. 217 00:14:53,680 --> 00:14:56,500 I'm going to use print that up. 218 00:15:00,890 --> 00:15:09,710 So let's try to print it in a more advanced way, as I just said, the total price is and the thing 219 00:15:09,710 --> 00:15:12,680 I'm going to do now is to put percentage. 220 00:15:13,250 --> 00:15:20,570 OK, this is a saved keyword once they appear together and only ones that appear together in a print 221 00:15:20,720 --> 00:15:21,470 percentage. 222 00:15:21,470 --> 00:15:21,900 Yes. 223 00:15:21,920 --> 00:15:28,910 OK, the total price is and then you can see here after the closing quotation mark, I'm going to do 224 00:15:28,910 --> 00:15:32,660 percentage and total rent price. 225 00:15:32,690 --> 00:15:37,520 OK, so what you see here is basically string formatting. 226 00:15:37,700 --> 00:15:42,350 OK, this is how I called and this is a more convenient way to print values. 227 00:15:43,180 --> 00:15:48,650 You can see that I put here percentages and after closing quotation marks, I put higher percentage 228 00:15:48,650 --> 00:15:52,970 and I'm putting the value that I want to be inserted in here. 229 00:15:54,140 --> 00:15:54,710 All right. 230 00:15:54,950 --> 00:15:57,110 It's not very difficult to understand. 231 00:15:58,020 --> 00:15:59,810 And also, I can do the following thing. 232 00:16:00,020 --> 00:16:09,550 I can pull if I want to put more than one value, I'm going to put in brackets here and a comma, OK? 233 00:16:09,770 --> 00:16:16,650 And then I can put an additional variable here and additional percentages here. 234 00:16:17,060 --> 00:16:19,480 OK, and now what's going to happen? 235 00:16:19,490 --> 00:16:20,670 The first percentage. 236 00:16:20,670 --> 00:16:21,070 Yes. 237 00:16:21,230 --> 00:16:22,550 Will receive this value. 238 00:16:22,580 --> 00:16:27,110 The first one and the second percentage will receive this value. 239 00:16:27,620 --> 00:16:30,010 OK, so from now on we'll dry. 240 00:16:30,110 --> 00:16:34,080 We're starting to use string formatting insert instead of this method. 241 00:16:34,100 --> 00:16:36,020 OK, so I'm just going to delete it. 242 00:16:37,740 --> 00:16:43,120 OK, she's going to delete this unwanted variable, and I think we are OK. 243 00:16:43,470 --> 00:16:43,980 All right. 244 00:16:44,610 --> 00:16:56,670 So also I want to bring the buffer, OK, so I'm going to do print the buffer years and then four percent 245 00:16:56,670 --> 00:16:56,730 the. 246 00:16:56,790 --> 00:16:58,920 Yes, and I'm percentage. 247 00:17:00,120 --> 00:17:06,630 Buffer, what's the name of the variable it is session price buffer. 248 00:17:08,160 --> 00:17:08,650 Yeah. 249 00:17:08,700 --> 00:17:09,380 All right. 250 00:17:09,750 --> 00:17:10,920 So there you have it. 251 00:17:11,130 --> 00:17:11,700 All right. 252 00:17:12,630 --> 00:17:13,550 There you have it. 253 00:17:13,740 --> 00:17:18,430 We have the string formatting here and we're printing these two values, OK? 254 00:17:18,510 --> 00:17:19,920 And just need to put spaces here. 255 00:17:21,880 --> 00:17:26,010 Yeah, like that, and there you have it, so we have the printout of the buffer. 256 00:17:26,200 --> 00:17:33,130 OK, it starts off zero is the default value, then it gets a value according to the season. 257 00:17:33,250 --> 00:17:39,190 And then if the apartment is more than one 30 meters, then he gets an additional zero point one. 258 00:17:39,490 --> 00:17:48,280 Just a quick reminder, this statement equals the following statement equals if I would write this. 259 00:17:50,070 --> 00:17:57,480 OK, so these two lines, thirty and thirty one, these are the same way I'm doing here is I'm taking 260 00:17:57,480 --> 00:18:02,010 the existing value and I'm saying add additional zero point one to the existing value. 261 00:18:03,210 --> 00:18:09,090 And right here, also inside this variable, I'm saying take the existing and add zero point one. 262 00:18:09,600 --> 00:18:10,770 We already covered it. 263 00:18:10,800 --> 00:18:14,450 But just a quick reminder to what it is. 264 00:18:14,610 --> 00:18:14,970 OK. 265 00:18:16,440 --> 00:18:18,590 OK, so I think we are done here. 266 00:18:19,830 --> 00:18:25,420 What this method will do is it will calculate the total return price. 267 00:18:25,450 --> 00:18:32,550 OK, and then at the end, what I want is to return total rental price outside of the method. 268 00:18:32,800 --> 00:18:38,700 OK, so once you apply some method and at the end you're putting a return. 269 00:18:38,760 --> 00:18:41,490 OK, so this value needs to go somewhere. 270 00:18:41,820 --> 00:18:51,450 And let's try first to execute this method using the instance of an object that we have created and 271 00:18:51,450 --> 00:18:55,560 then we'll see what we're going to do about this value and how can we extract it. 272 00:18:55,560 --> 00:19:07,260 OK, so this is the creation, OK, creation of an instance of an object one. 273 00:19:08,400 --> 00:19:14,330 OK, this is the second creation of the instance of an object. 274 00:19:14,550 --> 00:19:16,860 Let's focus on one of them and then we'll do the other. 275 00:19:16,870 --> 00:19:18,000 It's the same thing. 276 00:19:18,390 --> 00:19:22,470 So we have created the instance and now we're going to use this instance. 277 00:19:22,500 --> 00:19:31,330 OK, so what happens now is this instance would save would contain all of these properties inside it. 278 00:19:31,350 --> 00:19:38,490 OK, so once I want to execute a certain method, for example, rent calculation, I'm going to take 279 00:19:38,490 --> 00:19:45,450 the name of the instance and put that and then ran calculation. 280 00:19:45,750 --> 00:19:51,270 And what will happen here is this method would be executed by this instance. 281 00:19:51,330 --> 00:19:56,210 OK, but this instance contains these three properties. 282 00:19:56,400 --> 00:19:59,670 So all of these properties would be applied here. 283 00:19:59,940 --> 00:20:07,260 OK, these three properties are saved only for that instance in these three properties. 284 00:20:07,470 --> 00:20:18,540 And then each time a method, an object method is executed using a certain using a certain instance. 285 00:20:18,790 --> 00:20:20,340 OK, this instance. 286 00:20:20,580 --> 00:20:26,310 So automatically all of these three variables are applied inside the methods. 287 00:20:26,310 --> 00:20:32,940 If they are called in our case, we're calling out here for a season in the year. 288 00:20:33,150 --> 00:20:36,980 We're calling out for apartment size. 289 00:20:37,020 --> 00:20:40,830 OK, so these two are executed because they are call-out. 290 00:20:41,250 --> 00:20:49,020 And once we try to execute this method, we are using this instance to execute the method and this instance 291 00:20:49,020 --> 00:20:52,590 saved and stores all these values inside it. 292 00:20:52,920 --> 00:20:54,630 So they are applied inside here. 293 00:20:55,230 --> 00:20:55,670 All right. 294 00:20:56,490 --> 00:20:58,440 So let's try to run and see what happens. 295 00:20:58,800 --> 00:21:00,680 I press the wrong button. 296 00:21:01,020 --> 00:21:01,740 Let's run it. 297 00:21:02,770 --> 00:21:05,130 OK, so there you have it. 298 00:21:05,160 --> 00:21:11,420 OK, so first of all, let's go and do some flow check. 299 00:21:11,430 --> 00:21:11,880 All right. 300 00:21:12,720 --> 00:21:17,990 So first of all, best summer four and one thirty five. 301 00:21:18,180 --> 00:21:19,630 And let's see if it's OK. 302 00:21:19,680 --> 00:21:22,070 OK, so we're going through here, OK. 303 00:21:22,380 --> 00:21:26,510 And we getting to this method right here and we're getting to summer. 304 00:21:26,670 --> 00:21:31,570 OK, so if we got to summer, our season in a year is one point five. 305 00:21:31,620 --> 00:21:37,810 OK, then we're going down and our apartment size is one thirty five. 306 00:21:37,900 --> 00:21:45,720 OK, so once we get here, this is a true statement, meaning we're taking the existing buffer which 307 00:21:45,720 --> 00:21:50,610 is one point five and we're adding zero point one to it. 308 00:21:51,270 --> 00:21:57,390 And then we're going down here and we coming to this print, OK, in in this print we can see one point 309 00:21:57,390 --> 00:21:57,900 six. 310 00:21:58,380 --> 00:21:59,510 So this is correct. 311 00:21:59,520 --> 00:22:03,550 This is one point one plus zero point one. 312 00:22:03,660 --> 00:22:13,880 OK, and then we're coming to here and we having this calculation right here and we can see total ramp 313 00:22:13,920 --> 00:22:14,370 price. 314 00:22:14,580 --> 00:22:18,720 OK, so the default rent is two thousand. 315 00:22:18,780 --> 00:22:19,920 This is the default one. 316 00:22:20,190 --> 00:22:21,650 This is an internal variable. 317 00:22:22,050 --> 00:22:25,500 But then we are multiplying it by one point six. 318 00:22:25,650 --> 00:22:26,100 OK. 319 00:22:27,560 --> 00:22:34,550 And then we have three thousand two hundred dollars, OK, up until this point, everything is OK, 320 00:22:34,560 --> 00:22:36,230 so this method is covered. 321 00:22:36,380 --> 00:22:42,830 OK, we know how to use it and right now, let's try to execute the same method. 322 00:22:42,950 --> 00:22:44,250 But for this instance. 323 00:22:44,270 --> 00:22:55,630 OK, so this contract to that rent calculation like this and then in here between I'm going to do print 324 00:22:55,970 --> 00:22:56,720 slash in. 325 00:22:57,320 --> 00:22:58,520 You already know what it is. 326 00:22:58,550 --> 00:23:03,150 It just breaks up with a redundant line here between the printouts. 327 00:23:03,190 --> 00:23:05,090 OK, let's try it. 328 00:23:06,110 --> 00:23:06,860 All right. 329 00:23:06,860 --> 00:23:11,170 So here we have spring spring coming to this method. 330 00:23:11,180 --> 00:23:18,400 Here is one point for OK, and the apartment size is one hundred. 331 00:23:18,650 --> 00:23:22,830 So once we are checking this thing, it's a false statement. 332 00:23:22,850 --> 00:23:25,220 OK, so we're not adding zero point one. 333 00:23:25,520 --> 00:23:31,470 And then once we're printing the buffer, it should be the same as spring, which is one point for everything 334 00:23:31,490 --> 00:23:31,970 school. 335 00:23:32,270 --> 00:23:35,540 And right here below this is the total prize. 336 00:23:35,660 --> 00:23:40,670 Once 2000 was multiplied by zero point four. 337 00:23:40,670 --> 00:23:42,900 You can check it up with a calculator. 338 00:23:43,250 --> 00:23:44,810 This is a correct answer. 339 00:23:45,270 --> 00:23:46,130 All right. 340 00:23:46,400 --> 00:23:47,960 So we have covered this method. 341 00:23:48,740 --> 00:23:53,630 The only thing is left for us is to understand once we are returning a value. 342 00:23:53,900 --> 00:24:00,460 OK, I want to take this value basically, OK, total rent price and put it in here and said this method, 343 00:24:00,470 --> 00:24:04,650 OK, I want to use one the method value inside an additional method. 344 00:24:04,670 --> 00:24:12,380 OK, so in here I'm going to put total rent or maybe rent price. 345 00:24:12,600 --> 00:24:15,200 OK, I'm just giving any name I want. 346 00:24:15,360 --> 00:24:17,470 He does not have to be the same as this name. 347 00:24:17,480 --> 00:24:24,230 OK, as long as one variable would be passed into this method, it's all right. 348 00:24:24,360 --> 00:24:30,200 It doesn't have to be the same name that is inserted and the one that is received. 349 00:24:30,670 --> 00:24:36,920 OK, so once we want to parse this variable inside the method, they do not have to have the same name. 350 00:24:37,730 --> 00:24:38,930 It's all about the numbers. 351 00:24:38,930 --> 00:24:44,640 Like we're pressing one variable and one variable is received, then we are OK. 352 00:24:45,350 --> 00:24:48,200 The question is how do we proceed from here to here? 353 00:24:48,270 --> 00:24:52,980 OK, so this is like this is not the execution. 354 00:24:53,120 --> 00:24:55,340 OK, this is like what we're using. 355 00:24:55,340 --> 00:24:56,420 This is our tools. 356 00:24:56,750 --> 00:24:59,290 The execution is done from this part. 357 00:24:59,310 --> 00:24:59,570 Right. 358 00:25:01,100 --> 00:25:03,800 So first of all, we know how to use methods. 359 00:25:03,800 --> 00:25:08,750 We're just writing the name of the instance, then DOT and then the name of the method. 360 00:25:08,750 --> 00:25:17,720 So let's do it again for the second method, Lee's account, then the name of it is monthly maintenance. 361 00:25:17,720 --> 00:25:18,260 All right. 362 00:25:18,440 --> 00:25:25,590 And then we need to put some variable in here so that both are rent rent price. 363 00:25:25,610 --> 00:25:26,060 All right. 364 00:25:27,990 --> 00:25:33,160 So we have set up rent pricing here, but what is rent price, OK? 365 00:25:33,390 --> 00:25:35,690 It is like stuck inside this method. 366 00:25:35,940 --> 00:25:40,920 It's returned, but how can we pass it from this method to an additional method? 367 00:25:40,950 --> 00:25:43,830 OK, so listen closely. 368 00:25:44,730 --> 00:25:48,870 We have executed the rent calculation method from this line. 369 00:25:49,890 --> 00:25:58,300 OK, so we have executed this thing and then at the end we are returning this value. 370 00:25:59,460 --> 00:26:08,040 So in order to receive this value out of the method, we must put here rent. 371 00:26:09,150 --> 00:26:17,550 Price equals OK, and then after this method would be executed, the return from this, what I marked 372 00:26:17,550 --> 00:26:20,610 here, will go straight into rent price. 373 00:26:20,760 --> 00:26:26,070 OK, so total total rent price is returned. 374 00:26:26,340 --> 00:26:28,490 OK, it's returned from here. 375 00:26:29,100 --> 00:26:32,310 Sorry, it returned from here from this execution. 376 00:26:32,610 --> 00:26:38,940 And because its return is going to go straight into the variable that I've put here and then I don't 377 00:26:38,940 --> 00:26:42,440 have any problem because the total rent price is stored in here. 378 00:26:42,720 --> 00:26:48,540 And then from here I'm going to put it inside monthly maintenance bay execution. 379 00:26:48,870 --> 00:26:54,480 I'm just going to put it here, OK, this is this this means I'm passing a variable into the method, 380 00:26:54,480 --> 00:26:54,780 right? 381 00:26:55,290 --> 00:26:58,260 I'm placing it variable into the method this way. 382 00:26:59,370 --> 00:27:05,040 OK, so then the rent price would be received inside a monthly maintenance break. 383 00:27:05,290 --> 00:27:13,110 OK, now we have the rent price passed into it and now we can do some calculations. 384 00:27:13,450 --> 00:27:15,000 Let's create a new variable. 385 00:27:15,000 --> 00:27:18,560 Maintenance equals zero. 386 00:27:18,840 --> 00:27:34,740 And here, if our rent price is bigger, then let's say three thousand, then maintenance equals one 387 00:27:34,740 --> 00:27:35,250 hundred. 388 00:27:35,400 --> 00:27:39,570 Oh like this and üç. 389 00:27:41,950 --> 00:27:50,020 Maintenance equals maintenance equals 50, OK? 390 00:27:50,380 --> 00:27:57,820 Basically, what that means is that if we're paying a lot for the rent, meaning it's a popular time 391 00:27:57,820 --> 00:28:03,280 of the year or our apartment is very big, so the maintenance will be big as well. 392 00:28:04,150 --> 00:28:12,250 And if we are renting a smaller apartment and it's not a popular time of the year, so we're going to 393 00:28:12,250 --> 00:28:14,050 pay less for maintenance. 394 00:28:14,080 --> 00:28:14,430 OK. 395 00:28:15,310 --> 00:28:19,380 And of course, how can we verify that everything was fine here? 396 00:28:19,990 --> 00:28:20,920 Let's use the rent. 397 00:28:21,670 --> 00:28:26,230 The maintenance is then presented. 398 00:28:26,230 --> 00:28:26,740 Yes. 399 00:28:26,740 --> 00:28:27,790 As we know already. 400 00:28:28,150 --> 00:28:30,670 And then percentage maintenance. 401 00:28:32,750 --> 00:28:33,530 Yea, buddy. 402 00:28:33,780 --> 00:28:35,330 OK, we are good. 403 00:28:36,230 --> 00:28:39,170 All right, so let's try to execute. 404 00:28:39,500 --> 00:28:44,710 OK, we're going to have the maintenance from here and let's do the same thing from here. 405 00:28:45,140 --> 00:28:45,980 Same thing. 406 00:28:47,560 --> 00:28:50,920 OK, so we're going to put rent price. 407 00:28:50,930 --> 00:28:56,570 I'm going to put here number one and then put rent price number one here. 408 00:28:56,930 --> 00:29:01,430 And the same thing goes here, rent price, too. 409 00:29:03,410 --> 00:29:08,840 And then we're going to do lease contract to that. 410 00:29:10,300 --> 00:29:14,860 Monthly maintenance and rent price, too. 411 00:29:15,530 --> 00:29:21,310 OK, I think this is more understandable. 412 00:29:21,550 --> 00:29:25,170 This is this is method of execution. 413 00:29:26,910 --> 00:29:28,510 Methods, execution. 414 00:29:29,340 --> 00:29:31,740 And here it is, methods, execution. 415 00:29:32,100 --> 00:29:36,660 This is creation of an instance, this is method of execution and let's print it. 416 00:29:36,660 --> 00:29:39,950 And we are expecting to see the maintenance printed out as well. 417 00:29:42,830 --> 00:29:51,650 All right, so as you can see here, we have first rent prices, three thousand two hundred, then we're 418 00:29:51,650 --> 00:29:53,420 just going to discuss the monthly maintenance. 419 00:29:53,600 --> 00:29:53,920 All right. 420 00:29:54,140 --> 00:29:59,190 So we're going inside here and we're checking is the rent price above three thousand? 421 00:29:59,420 --> 00:30:01,280 In first case, it is. 422 00:30:01,280 --> 00:30:02,750 It is three thousand two hundred. 423 00:30:02,990 --> 00:30:06,230 So the maintenance is one hundred then printed. 424 00:30:06,950 --> 00:30:08,360 So it's the correct answer. 425 00:30:08,660 --> 00:30:13,880 In the second condition we're seeing here, the rent price, 2900. 426 00:30:13,910 --> 00:30:16,670 So once we're checking it, it's false. 427 00:30:16,880 --> 00:30:18,620 So you go straight to the Yael's. 428 00:30:19,010 --> 00:30:20,780 So 50 is the correct way. 429 00:30:22,370 --> 00:30:23,620 So there you have it. 430 00:30:23,780 --> 00:30:31,850 We have created an additional instance of an object classers, self barometer's methods of an object 431 00:30:32,000 --> 00:30:34,280 and we use the whole shebang here. 432 00:30:34,520 --> 00:30:40,210 And basically we have covered the object oriented programming the second time now. 433 00:30:40,460 --> 00:30:42,210 So I guess you should be good. 434 00:30:42,230 --> 00:30:51,020 Now I'm also going to remind you that the attachment file decoding file would be attached to this lecture 435 00:30:51,260 --> 00:30:57,110 and you can use it and you can copy paste it into your project and then do some manipulations here, 436 00:30:57,110 --> 00:31:03,500 because like changing the letters or changing the variables always helps for me to understand deeper 437 00:31:03,500 --> 00:31:04,490 what's going on here. 438 00:31:04,730 --> 00:31:09,110 OK, you can just remove some returns and see if it fails for you or not. 439 00:31:10,250 --> 00:31:15,050 I really recommend to do it because experiments really helps in learning. 440 00:31:16,340 --> 00:31:25,690 So this is this is the final the final thing that we're going to learn regarding object oriented programming. 441 00:31:25,730 --> 00:31:32,420 We have created two objects in this lecture and in the previous lecture as well. 442 00:31:33,320 --> 00:31:42,200 I think we covered it pretty nicely and we discussed the whole details of ILP programming in Python 443 00:31:43,130 --> 00:31:43,790 as well. 444 00:31:43,820 --> 00:31:46,820 Don't forget the string formatting that we have studied. 445 00:31:47,030 --> 00:31:54,650 So from now on, we're going to print things with the percentage assigned and the percentage of the 446 00:31:54,650 --> 00:31:58,280 name of the variable outside of the quotation marks. 447 00:31:58,520 --> 00:32:00,770 And this is the more professional way to do it. 448 00:32:01,970 --> 00:32:08,570 In the next lecture, we're going to head on to the practice part and the walk work home assignments 449 00:32:08,570 --> 00:32:10,780 regarding in Python. 450 00:32:11,750 --> 00:32:12,780 Don't worry about it. 451 00:32:12,780 --> 00:32:19,760 It shouldn't be too much difficult if you listen carefully to all of my explanations regarding object 452 00:32:19,760 --> 00:32:20,720 oriented programming. 453 00:32:21,050 --> 00:32:23,100 And I will see you in the next video. 454 00:32:23,240 --> 00:32:23,840 Bye bye.