1 00:00:12,720 --> 00:00:19,020 Hello to all the students, and in this video, we'll try to see the examples that we have been over 2 00:00:19,020 --> 00:00:20,070 in the previous lecture. 3 00:00:20,100 --> 00:00:20,400 All right. 4 00:00:20,760 --> 00:00:23,520 So once the project is open, just create a new file. 5 00:00:23,550 --> 00:00:29,520 As always, you can call it if statements basics, part two. 6 00:00:31,620 --> 00:00:34,500 And right here we can write if statements. 7 00:00:36,880 --> 00:00:40,650 BASIX far too surprisingly right. 8 00:00:40,920 --> 00:00:51,340 And let's bring out the age equals 30 variable that we really love and and then put a name variable 9 00:00:51,340 --> 00:00:52,540 equals to James. 10 00:00:54,030 --> 00:00:54,430 Right. 11 00:00:54,940 --> 00:01:02,250 And right here, let's see example number one, which will be logical operator. 12 00:01:03,100 --> 00:01:07,960 And in this example, we'll try to compare the age. 13 00:01:07,960 --> 00:01:16,140 We'll put age bigger than 20 and name double equals James. 14 00:01:16,180 --> 00:01:16,490 Right. 15 00:01:17,560 --> 00:01:19,470 So you can see both examples right here. 16 00:01:19,720 --> 00:01:25,600 The double equals and also the logical operator does have the opportunity to use them both. 17 00:01:25,700 --> 00:01:32,230 Here you can see that all of our material and all of our theory eventually comes together with strings, 18 00:01:32,860 --> 00:01:35,920 logical operators, double equals sign and so on. 19 00:01:36,370 --> 00:01:36,700 All right. 20 00:01:36,700 --> 00:01:40,720 So right here, let's just print example one. 21 00:01:41,800 --> 00:01:46,210 And we have my name is James and. 22 00:01:47,870 --> 00:01:48,560 I'm. 23 00:01:50,670 --> 00:01:52,200 Over 20. 24 00:01:54,670 --> 00:02:04,690 All right, and also I can drink now in some countries, I'm just joking, it's not educational for 25 00:02:04,690 --> 00:02:06,240 those of you who are under 18. 26 00:02:06,260 --> 00:02:07,450 It's not educational. 27 00:02:08,350 --> 00:02:08,650 All right. 28 00:02:08,920 --> 00:02:12,980 So you can see right here, my name is James and I'm over 20. 29 00:02:13,270 --> 00:02:21,250 And this one, we can see that once we to the logical operator right here, it's marked with orange. 30 00:02:21,250 --> 00:02:25,330 Same as if it means that this is a saved word in Python. 31 00:02:25,330 --> 00:02:29,170 It's saved for a special, special word. 32 00:02:29,440 --> 00:02:34,860 And you can see why it's special because it's used in if statements you see Boolean Operator. 33 00:02:35,590 --> 00:02:43,480 Well, it has many names, like it depends on which platform and where you read about it here. 34 00:02:43,480 --> 00:02:48,040 Pyfrom saw slabs, not slabs, though, called Jedburgh. 35 00:02:48,310 --> 00:02:54,390 The guys that who invented by charm, they call it Boolean Operator. 36 00:02:54,670 --> 00:02:55,090 All right. 37 00:02:55,300 --> 00:02:58,980 So you see it's a special word, same as if, for example. 38 00:02:59,380 --> 00:02:59,650 All right. 39 00:02:59,690 --> 00:03:05,110 By the way, if you want to read about if you can read about it once you hover above it, it's already 40 00:03:05,110 --> 00:03:07,930 recommended because you can learn from everything. 41 00:03:08,030 --> 00:03:12,560 Like, for example, you can read it and from here understand something you that you didn't know before. 42 00:03:13,030 --> 00:03:13,360 All right. 43 00:03:13,570 --> 00:03:16,510 And right here, we can put the alse. 44 00:03:17,700 --> 00:03:20,520 And both your example one. 45 00:03:22,690 --> 00:03:24,470 Default exit point. 46 00:03:24,490 --> 00:03:29,350 I'm writing this because I don't really care what they print, I just want to show just want to see, 47 00:03:29,350 --> 00:03:32,500 like, whether the code went to this bulk or to this bulk. 48 00:03:32,500 --> 00:03:32,770 Right. 49 00:03:33,160 --> 00:03:36,670 This is what interested me, the exit point. 50 00:03:37,390 --> 00:03:43,930 So both of these values must be true because we have there and logical operator, I hear once one of 51 00:03:43,930 --> 00:03:49,110 them will be false, that this thing would not be executed, but this thing would be executed. 52 00:03:49,330 --> 00:03:54,230 So let's try to feel it, feel it and see what happens. 53 00:03:54,700 --> 00:04:00,250 By the way, you can see here that we used a double equals Mark, and once I race one of them, we have 54 00:04:00,250 --> 00:04:06,670 an error because once we hover above it, yeah, we're having some kind of error here. 55 00:04:07,000 --> 00:04:10,660 Like the error error message doesn't even help us with anything. 56 00:04:11,290 --> 00:04:14,380 Python doesn't know what to do with what to do with it. 57 00:04:14,690 --> 00:04:15,130 That's it. 58 00:04:15,580 --> 00:04:18,960 So once we do this double equals log, everything's solved. 59 00:04:19,150 --> 00:04:19,440 All right. 60 00:04:19,660 --> 00:04:24,680 So right now, let's try to change it to Gaim and see whether this one would be executed. 61 00:04:24,700 --> 00:04:25,570 Let's try to run it. 62 00:04:27,120 --> 00:04:33,210 And as you can see, it goes straight to the default exit point because one of these values is false. 63 00:04:33,460 --> 00:04:33,810 All right. 64 00:04:33,820 --> 00:04:39,180 So for this one as well, like age is 30. 65 00:04:39,510 --> 00:04:45,100 And once we just change it, for example, we put Dan here. 66 00:04:45,120 --> 00:04:47,280 So this one would be false right now. 67 00:04:47,610 --> 00:04:48,480 Try to run it. 68 00:04:49,470 --> 00:04:51,240 Also default exit point. 69 00:04:51,520 --> 00:04:55,320 And once we turn it to 30, 30 is bigger than 20. 70 00:04:55,800 --> 00:04:59,070 We run it right now and everything's fine. 71 00:04:59,410 --> 00:04:59,730 Right. 72 00:04:59,910 --> 00:05:05,230 So this executes once this value and this value, they're both through output's. 73 00:05:05,400 --> 00:05:05,700 All right. 74 00:05:06,150 --> 00:05:08,700 Let's go straight ahead to the next example. 75 00:05:08,700 --> 00:05:12,030 And it's a similar to this one, actually. 76 00:05:12,030 --> 00:05:13,470 We don't need the second example. 77 00:05:13,470 --> 00:05:14,760 We can just use this. 78 00:05:14,760 --> 00:05:15,120 No. 79 00:05:15,720 --> 00:05:18,660 Yeah, we could just put here and change it to or. 80 00:05:19,800 --> 00:05:25,740 All right, or maybe the best thing to do is just copy it so you have it in your attachment file of 81 00:05:25,740 --> 00:05:28,010 code, both examples, right? 82 00:05:28,020 --> 00:05:29,450 So just copies right here. 83 00:05:31,510 --> 00:05:38,360 And then problem resolved, just change this one to two and this one to two as well, and he went in 84 00:05:38,360 --> 00:05:44,070 and out of space and he we need or it's already and here we put. 85 00:05:44,450 --> 00:05:45,160 All right. 86 00:05:45,160 --> 00:05:45,940 We'll find out. 87 00:05:46,040 --> 00:05:46,250 Right. 88 00:05:46,570 --> 00:05:50,110 Just copy all the bulk of code and just, I believe in shortcuts. 89 00:05:50,140 --> 00:05:50,500 All right. 90 00:05:51,400 --> 00:05:57,340 I believe in shortcuts because there are some specifical like specifical work that you don't need to 91 00:05:57,370 --> 00:06:03,130 rewrite it again because it's the same code we just change this value to or that seats don't need to 92 00:06:03,130 --> 00:06:03,970 write it again. 93 00:06:05,010 --> 00:06:05,970 Just market. 94 00:06:06,220 --> 00:06:06,490 Right. 95 00:06:06,520 --> 00:06:09,970 Click copy and paste it below. 96 00:06:10,030 --> 00:06:10,300 All right. 97 00:06:11,260 --> 00:06:18,010 So right here we have the same the same statements as we have in the first in the first example. 98 00:06:18,190 --> 00:06:19,750 But right here we have the order. 99 00:06:20,020 --> 00:06:26,420 And that means that once one of them is through one of these, that one or that one is true. 100 00:06:26,620 --> 00:06:31,760 So the values would be the output would run this code. 101 00:06:31,780 --> 00:06:32,170 All right. 102 00:06:33,180 --> 00:06:37,440 So let's see, let's run it first time was both of them true? 103 00:06:37,830 --> 00:06:44,790 So once both of them are true, you can see that the chunk below the difference because we need at least 104 00:06:44,790 --> 00:06:47,620 one and once both of them are true. 105 00:06:47,640 --> 00:06:49,770 So obviously this one will draw on. 106 00:06:50,040 --> 00:06:52,620 But also if I put a 10 here. 107 00:06:53,780 --> 00:06:59,570 All right, I don't care what happens in it, for example, for now, I specifically changed this value 108 00:06:59,570 --> 00:07:01,640 to see what happens in example number two. 109 00:07:01,640 --> 00:07:04,110 So ignore what you see, the output of you right now. 110 00:07:04,130 --> 00:07:04,400 All right. 111 00:07:05,060 --> 00:07:06,310 So just run it. 112 00:07:07,160 --> 00:07:07,660 All right. 113 00:07:07,670 --> 00:07:12,290 Still, you can see in the second example, my name is James and I'm over 20. 114 00:07:12,530 --> 00:07:14,060 So this line runs. 115 00:07:15,110 --> 00:07:23,040 All right, this one, this line runs, even though the output of this age, bigger than 20 is false. 116 00:07:23,070 --> 00:07:27,050 Once we have age equals then and only this one is true. 117 00:07:27,240 --> 00:07:31,410 So we can see that or logical operator works properly. 118 00:07:31,620 --> 00:07:36,850 And it helps us to determine even if one of them is one of them is true. 119 00:07:37,050 --> 00:07:40,890 So we will have a positive output right here under the IF. 120 00:07:41,910 --> 00:07:44,730 But what happens once both of them are false. 121 00:07:45,390 --> 00:07:45,840 All right. 122 00:07:45,840 --> 00:07:47,070 Both of them false. 123 00:07:47,340 --> 00:07:53,550 You can see an example, number two, that obviously goes to the default exit point, which is the false. 124 00:07:55,120 --> 00:08:00,730 All right, so that's about it, regarding the logical operators, they're pretty easy. 125 00:08:00,850 --> 00:08:01,230 All right. 126 00:08:01,240 --> 00:08:02,530 As you can see, pretty easy. 127 00:08:02,530 --> 00:08:06,150 Nothing special here and same as simple if statements. 128 00:08:06,160 --> 00:08:13,750 But now we have two statements in the same if and just we have a connector, which is the logical operator 129 00:08:13,750 --> 00:08:14,290 between them. 130 00:08:14,560 --> 00:08:14,890 All right. 131 00:08:14,980 --> 00:08:22,810 The third example will be dedicated, obviously, to the nested if because it's really important to 132 00:08:22,810 --> 00:08:23,380 understand. 133 00:08:23,380 --> 00:08:29,500 It's also how it will also help you further down the road with the final project. 134 00:08:29,800 --> 00:08:31,660 We're going to create at the end. 135 00:08:31,840 --> 00:08:32,310 All right. 136 00:08:32,590 --> 00:08:36,310 So right here, I'm just going to add another variable called Married. 137 00:08:37,700 --> 00:08:46,160 True, like that, and then I'm going to do like this, if age bigger than 20. 138 00:08:47,890 --> 00:08:50,740 And name equals. 139 00:08:52,010 --> 00:08:52,850 James. 140 00:08:54,030 --> 00:09:03,060 Just copying the top the top line right here and then, all right, so just want just a quick reminder, 141 00:09:03,610 --> 00:09:10,550 the nested if statements says that under the first main, if we going to insert the nested part. 142 00:09:10,770 --> 00:09:15,330 So right here, we're going to have another if and just going to put here married. 143 00:09:17,390 --> 00:09:24,170 Double equals true, which is a boolean variable, right, if married equals true, then I'm going to 144 00:09:24,170 --> 00:09:31,220 say to the guy, first of all, example three, good luck. 145 00:09:33,020 --> 00:09:39,590 It's gonna be a long, happy road, right? 146 00:09:39,980 --> 00:09:41,180 Being optimistic. 147 00:09:41,780 --> 00:09:44,420 Yeah, it's not cynical. 148 00:09:45,410 --> 00:09:47,610 I'm really not. 149 00:09:47,750 --> 00:09:48,520 All right. 150 00:09:48,550 --> 00:09:48,770 Yeah. 151 00:09:49,100 --> 00:09:51,020 It's going to be a long happy. 152 00:09:51,020 --> 00:09:51,320 Right. 153 00:09:51,590 --> 00:09:52,040 All right. 154 00:09:52,040 --> 00:09:58,850 So if you're bigger if you're older than twenty and your name is James and you're married. 155 00:09:59,060 --> 00:09:59,510 All right. 156 00:09:59,510 --> 00:10:03,110 You're hearing me, James, if there is a student named James is for you. 157 00:10:03,440 --> 00:10:03,850 Right. 158 00:10:05,180 --> 00:10:09,770 So if this would be true, both of these values would be true. 159 00:10:09,920 --> 00:10:15,760 And then if only if both of them are true, we're going to go inside here. 160 00:10:16,190 --> 00:10:16,760 But. 161 00:10:18,060 --> 00:10:21,270 We're going to do it here, the nested. 162 00:10:25,050 --> 00:10:27,570 Nested alse. 163 00:10:29,820 --> 00:10:37,110 Yeah, and you need to dots here and also we need to have the parent else as well. 164 00:10:38,800 --> 00:10:40,410 Uh prent. 165 00:10:41,430 --> 00:10:42,810 Example three. 166 00:10:45,030 --> 00:10:46,950 An apparent. 167 00:10:48,510 --> 00:10:51,210 Parent alse, yeah. 168 00:10:53,030 --> 00:10:56,630 All right, so that's about it, so you can see the following flow. 169 00:10:56,690 --> 00:10:58,200 We're going from top to bottom. 170 00:10:59,150 --> 00:11:00,760 We're coming this line right here. 171 00:11:00,950 --> 00:11:10,700 And the question is age above 20 through then we have and yeah, then we have the end name equals James 172 00:11:10,700 --> 00:11:11,620 also Drew. 173 00:11:11,630 --> 00:11:16,280 And just because of because both of them are true, we're going to this chunk right here. 174 00:11:16,490 --> 00:11:19,670 We're not caring about this L'Esperance here. 175 00:11:19,910 --> 00:11:23,840 We're just interested in the chunk below the left and right here. 176 00:11:23,840 --> 00:11:30,380 We also have additional if this one is in nested if and we ask again, is married equals true. 177 00:11:31,280 --> 00:11:35,540 And if it's true, we run this code if it's false on this code. 178 00:11:35,750 --> 00:11:36,140 All right. 179 00:11:36,350 --> 00:11:42,630 Let's try to fail it, fail it in advance and and try to get this line right here. 180 00:11:42,650 --> 00:11:49,640 So basically, what we need, we need to fail one of these terms right here and then fail the if statement 181 00:11:49,640 --> 00:11:50,030 right here. 182 00:11:50,090 --> 00:11:53,570 So, first of all, going to put false not married. 183 00:11:53,580 --> 00:11:54,830 So this one would be false. 184 00:11:55,700 --> 00:11:57,160 This will help us to get here. 185 00:11:57,350 --> 00:12:02,720 And also, I'm going to change the age to 10 going around the code now. 186 00:12:02,900 --> 00:12:06,140 And the only thing that interests me is example number three. 187 00:12:07,040 --> 00:12:08,870 All right, great. 188 00:12:10,220 --> 00:12:13,460 Not really great because I made a mistake. 189 00:12:13,700 --> 00:12:16,990 And it's a good mistake because we can learn from it once. 190 00:12:17,030 --> 00:12:18,420 This one is false. 191 00:12:18,440 --> 00:12:21,860 So all of the code got to go down here. 192 00:12:22,780 --> 00:12:23,510 And why? 193 00:12:23,800 --> 00:12:29,770 Because we need both of them to be true in order to get to this part that I marked right here, and 194 00:12:29,770 --> 00:12:33,660 once this one is false, we're going straight ahead to the parent house. 195 00:12:33,970 --> 00:12:37,900 So let's get it back to be 30 and run it right now. 196 00:12:37,900 --> 00:12:40,880 And we'll get to this line right here, Ron. 197 00:12:42,970 --> 00:12:43,250 Hoo. 198 00:12:43,270 --> 00:12:43,630 Yeah. 199 00:12:43,960 --> 00:12:44,650 So. 200 00:12:46,310 --> 00:12:47,060 This false. 201 00:12:48,160 --> 00:12:51,890 This one is sorry, this one is true, this one is true. 202 00:12:52,330 --> 00:12:57,190 Now we got to this chunk right here and we're asking if married is true. 203 00:12:57,400 --> 00:13:01,250 And the answer to this part is false because it is not true. 204 00:13:01,360 --> 00:13:01,990 It's false. 205 00:13:02,200 --> 00:13:04,600 So this one is a false statement, right? 206 00:13:04,720 --> 00:13:06,310 Remember this sentence? 207 00:13:06,310 --> 00:13:08,020 It's a false statement. 208 00:13:08,290 --> 00:13:08,830 It's not. 209 00:13:08,840 --> 00:13:09,950 It's like it's a lie. 210 00:13:10,000 --> 00:13:11,710 In other words, this one is a lie. 211 00:13:12,250 --> 00:13:15,610 This one is a lie because married equals true. 212 00:13:15,610 --> 00:13:16,510 It's a lie now. 213 00:13:16,510 --> 00:13:17,700 Married equals false. 214 00:13:17,710 --> 00:13:18,570 So it's a lie. 215 00:13:19,150 --> 00:13:21,950 So because it's a lie, we're going here to the house. 216 00:13:22,420 --> 00:13:23,510 Very, very simple. 217 00:13:24,220 --> 00:13:24,550 All right. 218 00:13:24,760 --> 00:13:28,540 I think this covers the advance sorry. 219 00:13:28,540 --> 00:13:30,220 The bases, part two. 220 00:13:30,340 --> 00:13:36,000 And we have seen lots of examples in the previous lecture and we have seen them in live right by charm. 221 00:13:36,280 --> 00:13:42,690 I think we're ready to go ahead and start the advance part of if statements over there. 222 00:13:42,700 --> 00:13:46,020 We'll see much more examples will expand our knowledge. 223 00:13:46,030 --> 00:13:52,090 And right after we will have a wide assignment for these statements because it's really important to 224 00:13:52,090 --> 00:13:52,810 understand it. 225 00:13:53,140 --> 00:13:59,860 And also, don't hesitate to try to resolve your assignments by yourselves after the advanced lectures. 226 00:14:00,200 --> 00:14:01,290 And that's about it. 227 00:14:01,300 --> 00:14:02,810 I will see you in the next video. 228 00:14:02,830 --> 00:14:03,310 Thank you.