1 00:00:13,360 --> 00:00:19,680 Hello to all of my students, and now we're just going to see some examples regarding your state's statements, 2 00:00:19,690 --> 00:00:27,190 the basic part, and I was always a fan of starting easy and then like increasing the speed. 3 00:00:27,460 --> 00:00:31,540 So to understand all the basics, you always have to start from basics, right? 4 00:00:31,570 --> 00:00:35,850 You can just go from zero to 60 in one second. 5 00:00:35,860 --> 00:00:45,010 And I'm always a believer of getting the things breaking down into small pieces and go further in steps. 6 00:00:45,170 --> 00:00:45,460 All right. 7 00:00:46,060 --> 00:00:49,510 So once you open your project, just create a new file. 8 00:00:49,690 --> 00:00:55,060 You can call it if statements basics. 9 00:00:56,170 --> 00:01:02,500 And right now, I'm just going to show you some examples from the previous lecture so it could sink 10 00:01:02,680 --> 00:01:04,180 in your in your mind. 11 00:01:04,330 --> 00:01:09,980 And I think we'll get the hang of if statements more easily after seeing these examples. 12 00:01:10,660 --> 00:01:11,080 All right. 13 00:01:11,090 --> 00:01:17,140 So first of all, let's just create here a comment for us in the future, as always. 14 00:01:17,360 --> 00:01:20,930 And let's head off with a simple example. 15 00:01:20,950 --> 00:01:30,760 So, first of all, let's create a salary variable integer that set is as a thousand and let's return 16 00:01:30,760 --> 00:01:31,400 each statement. 17 00:01:31,420 --> 00:01:40,060 So I just want to say that if salary is bigger, right, because this mathematical sign points towards 18 00:01:40,060 --> 00:01:49,210 salary, this means salaries bigger, then five thousand, then two that I want to print. 19 00:01:50,650 --> 00:01:54,330 My salary is too low. 20 00:01:54,380 --> 00:01:58,120 I need to change my job, so sort of a joke. 21 00:01:58,660 --> 00:01:59,230 All right. 22 00:02:00,700 --> 00:02:01,090 All right. 23 00:02:01,090 --> 00:02:09,970 And then right here else, as you recall from the previous lecture, like if this is the output of that 24 00:02:09,970 --> 00:02:11,630 statement is true. 25 00:02:12,010 --> 00:02:14,140 So this would be executed. 26 00:02:14,140 --> 00:02:16,200 Everything under the earth would be executed. 27 00:02:16,210 --> 00:02:23,380 But if it's not true, meaning it's false, the house is the default exit point, meaning that if this 28 00:02:23,390 --> 00:02:27,000 won't be ran, so everything under else would run. 29 00:02:27,100 --> 00:02:27,420 All right. 30 00:02:27,970 --> 00:02:33,190 And right here, I want to say salary is above 5000. 31 00:02:34,630 --> 00:02:35,860 It's OK for now. 32 00:02:35,900 --> 00:02:36,160 Right. 33 00:02:36,670 --> 00:02:43,350 So and this statement we can see here a true value because our salary is eight thousand. 34 00:02:43,360 --> 00:02:51,880 And the statement says the salary is above five thousand and this is actually above above five thousand. 35 00:02:51,890 --> 00:02:54,850 So this we expect this one to print. 36 00:02:55,210 --> 00:02:57,360 Let's run it and make sure that this happens. 37 00:02:58,150 --> 00:02:58,640 Great. 38 00:02:58,720 --> 00:02:59,770 So as you can see. 39 00:03:00,160 --> 00:03:05,950 Yeah, the statement, the print under the if condition was printed out. 40 00:03:06,190 --> 00:03:08,080 And let's just try to play with it a little bit. 41 00:03:09,110 --> 00:03:15,980 Let's just set here four thousand nine hundred ninety nine and let's run it now. 42 00:03:17,800 --> 00:03:18,360 All right. 43 00:03:18,550 --> 00:03:24,130 As you can see accordingly, as we change the value of the salary, which is now smaller or smaller 44 00:03:24,130 --> 00:03:25,360 than five thousand. 45 00:03:25,690 --> 00:03:32,290 Now, it's it did not print this print out, went to alse, which is the point. 46 00:03:32,290 --> 00:03:41,260 And after that, the cold exits the if completely meaning whether this printout out or this this out 47 00:03:41,440 --> 00:03:47,430 after one of them is executed, the code goes down to here and sorry. 48 00:03:47,440 --> 00:03:47,920 Here. 49 00:03:48,970 --> 00:03:49,330 Yeah. 50 00:03:51,600 --> 00:03:58,070 Just want to show you, like going here, yeah, and going down here, exit the if statements completely. 51 00:03:58,080 --> 00:03:59,790 All right, so it runs only one time. 52 00:04:00,450 --> 00:04:04,350 But let's see what happens if we put 5000. 53 00:04:04,350 --> 00:04:04,820 Exactly. 54 00:04:04,830 --> 00:04:08,280 So 5000 is 5000, bigger than 5000. 55 00:04:09,360 --> 00:04:10,150 Anyone knows. 56 00:04:10,680 --> 00:04:12,540 So the answer is. 57 00:04:16,100 --> 00:04:20,810 Yep, the answer is this one false. 58 00:04:21,020 --> 00:04:27,940 All right, so why because 5000 is not bigger than 5000, it equals the five thousand. 59 00:04:27,950 --> 00:04:35,090 But if we put an equals mark right here like this, this means we can do we can put two operators here, 60 00:04:35,210 --> 00:04:37,640 pool math, two math operators here. 61 00:04:37,940 --> 00:04:46,220 We're saying here, if it's equal, if it's bigger, if salaries bigger or equals 5000, then execute 62 00:04:46,220 --> 00:04:47,130 this line right here. 63 00:04:47,510 --> 00:04:48,560 So let's run it. 64 00:04:49,700 --> 00:04:50,340 Whoa. 65 00:04:50,360 --> 00:04:50,780 Yet. 66 00:04:50,810 --> 00:04:56,840 So we can see that this one was printed out because we added the equals mark right here, meaning it's 67 00:04:56,840 --> 00:04:59,690 bigger or equals than 5000. 68 00:04:59,700 --> 00:05:00,970 So this statement is true. 69 00:05:01,880 --> 00:05:03,720 But once we removed this one. 70 00:05:03,980 --> 00:05:05,870 So this statement is false. 71 00:05:06,140 --> 00:05:08,360 And once it's false, this will not run. 72 00:05:08,690 --> 00:05:11,900 The default exit point will be executed, which is the yellow. 73 00:05:12,680 --> 00:05:16,430 So as you just saw, I did some experiments here. 74 00:05:16,430 --> 00:05:18,770 And programming is all about experience. 75 00:05:18,770 --> 00:05:20,990 My friends, you always need to experiment. 76 00:05:20,990 --> 00:05:25,040 And once you see, like a statement that you're not really familiar with and you don't really know what 77 00:05:25,040 --> 00:05:26,930 it does, just try to play with it. 78 00:05:26,930 --> 00:05:31,400 Just try to change the values right here and see what will happen that way. 79 00:05:31,850 --> 00:05:37,240 According to the output, you can learn about the body of the statement that we're learning. 80 00:05:37,460 --> 00:05:37,750 All right. 81 00:05:37,760 --> 00:05:42,070 So just changing the values here made me learn a lot about the statement. 82 00:05:42,940 --> 00:05:45,320 Let's go over to the next statement. 83 00:05:46,250 --> 00:05:48,890 I'm just going to put age 30 here. 84 00:05:48,890 --> 00:05:59,050 And if age is bigger than 50, then I want to present you are above 50. 85 00:06:01,490 --> 00:06:05,120 You are a senior developer for sure. 86 00:06:06,080 --> 00:06:06,470 Yep. 87 00:06:06,740 --> 00:06:07,430 Just a joke. 88 00:06:07,440 --> 00:06:07,700 Right? 89 00:06:08,930 --> 00:06:10,940 Then we can put an L if here. 90 00:06:11,150 --> 00:06:18,260 And if you recall from the previous video, we used one example for if else only and one example for 91 00:06:18,440 --> 00:06:24,770 if ayliffe example, once we have several options, several conditions. 92 00:06:24,770 --> 00:06:40,700 So if age bigger than 40 and right now we want to present you, your age is bigger than 40, you are 93 00:06:41,540 --> 00:06:44,600 a developer for some time. 94 00:06:46,200 --> 00:06:47,100 But if not. 95 00:06:48,320 --> 00:06:51,920 It's better late than never. 96 00:06:52,040 --> 00:06:52,580 All right. 97 00:06:54,190 --> 00:06:59,000 I really believe in this sentence because I always believed in challenging yourself, not doesn't matter 98 00:06:59,000 --> 00:07:01,460 what age you are, and it's never too late. 99 00:07:01,640 --> 00:07:02,000 All right. 100 00:07:03,350 --> 00:07:05,210 So this one was the second statement. 101 00:07:05,210 --> 00:07:10,700 And let's add another one, a much bigger than thirty five. 102 00:07:15,270 --> 00:07:25,320 So you are more than thirty five years old, I might guess you are a developer. 103 00:07:25,370 --> 00:07:27,450 I'm I'm running out of ideas, actually. 104 00:07:28,140 --> 00:07:28,500 All right. 105 00:07:28,510 --> 00:07:31,490 So this one is another else. 106 00:07:31,500 --> 00:07:35,710 If you remember, that leaf is a short for ayliffe. 107 00:07:35,930 --> 00:07:36,290 All right. 108 00:07:36,900 --> 00:07:41,850 And here in the house, just want to print. 109 00:07:43,290 --> 00:07:44,550 Doesn't matter. 110 00:07:44,640 --> 00:07:47,940 Doesn't matter what age you are. 111 00:07:49,050 --> 00:07:51,310 Let's called Biton. 112 00:07:52,200 --> 00:07:52,600 Yeah. 113 00:07:53,970 --> 00:08:02,430 So right now we have all these statements written down here and our age is 30 or so. 114 00:08:02,430 --> 00:08:03,650 Is this statement true? 115 00:08:05,040 --> 00:08:06,030 It's about 50. 116 00:08:06,660 --> 00:08:08,340 Age is bigger than 50. 117 00:08:08,340 --> 00:08:09,660 No age is 30. 118 00:08:09,670 --> 00:08:11,120 So this statement is false. 119 00:08:11,130 --> 00:08:12,570 It would not be executed. 120 00:08:13,320 --> 00:08:15,330 Is age bigger than 40? 121 00:08:15,420 --> 00:08:16,660 No, it's false. 122 00:08:16,680 --> 00:08:19,170 So this one would not be executed as well. 123 00:08:19,530 --> 00:08:21,890 Is bigger than the thirty five false as well. 124 00:08:22,110 --> 00:08:29,730 So what are we going to be a game come up with is this default mode, which is the LTH because all of 125 00:08:29,730 --> 00:08:34,020 these are false for now and this one is the default exit point. 126 00:08:34,440 --> 00:08:40,810 If none of these will be true, the owls would be executed as the default exit point. 127 00:08:41,160 --> 00:08:42,480 So let's try to run it. 128 00:08:43,820 --> 00:08:44,210 All right. 129 00:08:44,970 --> 00:08:53,280 So you see it right now that in matter of fact, like the else was printed and this was the exit point. 130 00:08:53,280 --> 00:08:53,550 All right. 131 00:08:53,910 --> 00:08:56,300 Again, let's try to just do some manipulations here. 132 00:08:56,310 --> 00:09:01,110 Let's just put the age three hundred, all right, like we're a mommy or something. 133 00:09:01,440 --> 00:09:06,420 And once we run it, let's see what happens. 134 00:09:06,960 --> 00:09:07,470 All right. 135 00:09:07,830 --> 00:09:12,620 This this sentence like this if statement was first in line. 136 00:09:12,870 --> 00:09:17,370 So this was the first one to be checked and it came up true. 137 00:09:17,610 --> 00:09:21,670 So this print was executed and once one of them. 138 00:09:21,720 --> 00:09:22,170 All right. 139 00:09:22,490 --> 00:09:29,310 I'm focusing on the sentence once one of them was executed or in other words, once one of these alif 140 00:09:29,550 --> 00:09:40,380 or if one of these conditions was true, the code exits the whole bulk of if completely and continues 141 00:09:40,380 --> 00:09:41,010 down here. 142 00:09:43,500 --> 00:09:44,040 All right. 143 00:09:44,040 --> 00:09:46,370 That's just verified, right? 144 00:09:47,370 --> 00:09:54,390 You see, so once this statement was true and the print this print was executed, they called after 145 00:09:54,570 --> 00:10:00,860 finishing with all of this part because one of them was true, went over to this point right here. 146 00:10:00,870 --> 00:10:09,150 And it ignores all the other else if and Elsas and if so, only one of them can be executed. 147 00:10:09,150 --> 00:10:16,230 And the first one that would be true would be the one to be executed, even though even though that 148 00:10:16,230 --> 00:10:17,960 this statement is also true. 149 00:10:17,970 --> 00:10:18,300 Right. 150 00:10:18,450 --> 00:10:20,940 Because the age is 300 and it's bigger than 40. 151 00:10:21,120 --> 00:10:21,990 Doesn't matter. 152 00:10:22,140 --> 00:10:23,310 It doesn't matter. 153 00:10:24,180 --> 00:10:29,820 The Python Python programming the if statement in Python programming works that way that only the first 154 00:10:29,820 --> 00:10:34,380 true statement would be executed and all the rest would be ignored. 155 00:10:35,730 --> 00:10:36,150 All right. 156 00:10:36,150 --> 00:10:40,050 So that's about it for the advanced part, the basics one part. 157 00:10:40,230 --> 00:10:47,470 And these examples are too huge to be deployed after we learned that during the previous lecture. 158 00:10:48,150 --> 00:10:53,730 So this gives you the feeling what if statements are all about and you see some examples you really 159 00:10:53,730 --> 00:10:55,470 recommend to take this code. 160 00:10:55,710 --> 00:11:02,180 You have it attached to your lecture and to paste it in your pie chart and start to play. 161 00:11:02,190 --> 00:11:08,220 Playing with it like adding equals here and changing the numbers as well as we did right here just to 162 00:11:08,220 --> 00:11:10,140 get the hang of it much better. 163 00:11:10,350 --> 00:11:14,750 And I'll see you in the next video where we can see some more advanced examples. 164 00:11:14,790 --> 00:11:15,860 Thank you and bye bye.