1 00:00:00,890 --> 00:00:07,670 Conditional programming or branching is something you do every day, every moment. 2 00:00:07,700 --> 00:00:11,930 It's about evaluating conditions if the light is red. 3 00:00:13,360 --> 00:00:14,650 Then I can cross. 4 00:00:16,280 --> 00:00:18,170 If I'm hungry, I need to eat. 5 00:00:18,940 --> 00:00:23,940 And if I'm late for work, then I will call my boss. 6 00:00:23,950 --> 00:00:30,790 And the main tool is the if statement, which comes in different forms and colors. 7 00:00:30,790 --> 00:00:38,440 But its basic function is to evaluate an expression and based on the result, choose which part of the 8 00:00:38,440 --> 00:00:39,670 code to execute. 9 00:00:39,700 --> 00:00:43,860 As usual, let's look at this example here. 10 00:00:43,870 --> 00:00:52,630 So if I am Am is late here and true here true. 11 00:00:52,630 --> 00:00:54,070 And after that we will. 12 00:00:54,070 --> 00:00:58,510 If is late is true, then print. 13 00:00:58,690 --> 00:01:03,070 I need I need to get. 14 00:01:03,430 --> 00:01:07,720 I need to call my boss. 15 00:01:09,850 --> 00:01:11,110 And this is possible. 16 00:01:11,110 --> 00:01:12,610 The simplest example. 17 00:01:12,610 --> 00:01:22,150 So when fed to if statement the is late acts as a conditional expression which is evaluated in a boolean 18 00:01:22,150 --> 00:01:22,690 context. 19 00:01:22,690 --> 00:01:25,090 And remember that is late here. 20 00:01:25,120 --> 00:01:31,180 This is late variable here is boolean, not a string. 21 00:01:31,180 --> 00:01:31,750 Not. 22 00:01:33,110 --> 00:01:35,240 Value tuple or anything. 23 00:01:35,240 --> 00:01:36,350 It is a boolean. 24 00:01:36,350 --> 00:01:38,150 It's another primitive type. 25 00:01:38,240 --> 00:01:39,380 Boolean. 26 00:01:39,740 --> 00:01:43,660 You will learn about that in next lectures also. 27 00:01:43,670 --> 00:01:44,510 So. 28 00:01:45,580 --> 00:01:51,460 Uh, so Boolean also can Boolean has two values, either false or true. 29 00:01:51,490 --> 00:01:58,210 So if the result of the evaluation is true, then we enter the body of the code immediately after the 30 00:01:58,210 --> 00:01:58,930 if statement. 31 00:01:58,960 --> 00:02:07,960 Notice that the print instruction is indented, which means that it belongs to scope defined by the 32 00:02:07,960 --> 00:02:08,980 if here. 33 00:02:08,980 --> 00:02:11,020 And that's because this is indentation here. 34 00:02:12,160 --> 00:02:17,560 So if we run this code, as you can see, I need to call my boss. 35 00:02:17,590 --> 00:02:19,450 If we make it is late. 36 00:02:19,450 --> 00:02:19,930 False. 37 00:02:19,930 --> 00:02:22,150 So we are not late for now. 38 00:02:22,150 --> 00:02:24,820 And as you can see, we didn't evaluate anything. 39 00:02:24,820 --> 00:02:29,410 So this code is didn't work or didn't need it to work here. 40 00:02:29,500 --> 00:02:37,390 So depending on the result of evaluating the late is late expression, we can either enter block one 41 00:02:37,390 --> 00:02:39,640 or block two, but not both. 42 00:02:39,640 --> 00:02:48,430 So block one is executed when late evaluates to true while block two here is executed when the late 43 00:02:48,430 --> 00:02:49,960 evaluates to false. 44 00:02:49,960 --> 00:02:54,850 So try and assigning false and true to this is late too. 45 00:02:55,360 --> 00:02:59,830 To see how the output of this code changes accordingly. 46 00:02:59,830 --> 00:03:08,260 So in this example also introduced the else clause in which becomes very handy when we want to provide 47 00:03:08,260 --> 00:03:11,380 an alternative set of instructions to be executed. 48 00:03:11,380 --> 00:03:15,320 When an expression evaluates to false within an if class. 49 00:03:15,320 --> 00:03:21,740 So the class is optional, as is evident by comparing preceding two examples. 50 00:03:21,740 --> 00:03:25,460 And in with these examples we will do in next lecture. 51 00:03:25,460 --> 00:03:26,210 So I'm waiting you in. 52 00:03:26,210 --> 00:03:26,750 Next lecture.