1 00:00:00,150 --> 00:00:09,060 We will not discuss about the if and STATEMENT The if any statement executed one set of statements when 2 00:00:09,060 --> 00:00:10,950 the condition is true. 3 00:00:13,240 --> 00:00:20,350 That means the boolean expression is true the if block would get executed. 4 00:00:21,680 --> 00:00:27,200 And a different set of statements when the condition is false. 5 00:00:27,200 --> 00:00:31,030 So if they boolean expression is false. 6 00:00:31,100 --> 00:00:39,870 The program comes to the else clause and then executes these statements. 7 00:00:39,890 --> 00:00:49,780 In the end its clause so the if edited statement allows us to follow two courses of action. 8 00:00:50,160 --> 00:00:53,870 And this is the syntax for the failed statement. 9 00:00:54,780 --> 00:01:04,540 If the boolean expression evaluates to false then all of the statements in the if block are skipped. 10 00:01:05,740 --> 00:01:12,080 And instead all these statements under the else clause are executed. 11 00:01:12,140 --> 00:01:15,490 So consider here an example. 12 00:01:15,830 --> 00:01:25,610 I have an if statement here with this condition the condition checks if the variable colored is equal 13 00:01:25,610 --> 00:01:26,450 to the string. 14 00:01:26,510 --> 00:01:36,160 Green and if this boolean expression evaluates TRUE TRUE IT PRINTS this next go. 15 00:01:36,470 --> 00:01:41,690 And if this boolean expression evaluates true false. 16 00:01:41,690 --> 00:01:48,990 That is the if condition is false then the program comes to the edit class and prints. 17 00:01:49,010 --> 00:01:50,360 This takes 18 00:01:54,240 --> 00:02:03,630 so here in this example I have assigned the text Green to the variable color and I pass the variable 19 00:02:03,630 --> 00:02:07,620 to the if clause and if this is true. 20 00:02:07,620 --> 00:02:16,920 That means if the color is green then those text go is gonna be printed as if this is not true. 21 00:02:17,100 --> 00:02:23,100 This text Stop it will be printed so let's execute this cell. 22 00:02:24,380 --> 00:02:36,500 So since color is assigned to green and since this is true this text is printed now in order to execute 23 00:02:36,500 --> 00:02:38,960 the set of statements in the else clause. 24 00:02:38,990 --> 00:02:46,790 I'm gonna change the code here that is I'm gonna change the boolean expression and I'm going to check 25 00:02:46,940 --> 00:02:54,870 if the color is red and then execute this cell again. 26 00:02:55,010 --> 00:03:06,740 So this time since the color code is not equal to this text it read the if statement does not get executed. 27 00:03:07,720 --> 00:03:13,870 But the program goes to the S Class and print did text here. 28 00:03:13,870 --> 00:03:18,790 Now let's talk about the if a live L statement. 29 00:03:18,790 --> 00:03:29,330 Sometimes there are more than two possibilities and we need more than two conditions so in that case 30 00:03:29,390 --> 00:03:36,340 we can use the if a live L statement and it is used when we need to check multiple conditions 31 00:03:38,900 --> 00:03:44,940 and this is D syntax for the if a live is statement. 32 00:03:46,730 --> 00:03:50,570 A list is an abbreviation for it. 33 00:03:50,690 --> 00:04:00,990 If and there is no limit on the number of a live statement but there should be only one else statement. 34 00:04:01,210 --> 00:04:11,980 So out of all of these blogs it is the if block here and then the Elif Elif again and else blog only 35 00:04:12,040 --> 00:04:14,470 one block of code gets executed. 36 00:04:16,470 --> 00:04:23,210 If the condition is true then the code inside the if block gets executed. 37 00:04:24,880 --> 00:04:30,790 If the condition is false then the next condition is evaluated. 38 00:04:30,790 --> 00:04:39,040 That means the Elif condition is evaluated and if this is false the program checks. 39 00:04:39,040 --> 00:04:45,690 If the next a live condition is true or not and so on. 40 00:04:45,740 --> 00:04:55,720 Finally if all of these conditions it is the if and the Elif conditions are false then the block of 41 00:04:55,720 --> 00:05:00,170 code in the edits clause get executed. 42 00:05:00,250 --> 00:05:06,580 That is if none of the conditions is true then the code inside it gets executed. 43 00:05:07,540 --> 00:05:10,080 So let's look at this example. 44 00:05:10,150 --> 00:05:17,260 I have assigned a text Green to the variable colored and because I have multiple conditions to check 45 00:05:17,560 --> 00:05:20,950 I'm going to use the if elif L statement. 46 00:05:21,160 --> 00:05:31,820 So I'm going to assign the text to green to these variable coloured and then the if clause is one to 47 00:05:31,820 --> 00:05:34,610 check if the color is green or not. 48 00:05:35,510 --> 00:05:42,530 If this is true it's going to print this text Gore and I have one a block which is going to check if 49 00:05:42,530 --> 00:05:46,970 the color is yellow if this is true it's going to print. 50 00:05:47,080 --> 00:05:54,030 We and if the if and a live blog conditions are false. 51 00:05:55,740 --> 00:06:00,360 The control goes to the else block and prints text here. 52 00:06:01,250 --> 00:06:04,540 So let's execute this piece of code. 53 00:06:05,780 --> 00:06:13,860 Since colored is assigned to green the first condition that is the if condition is true and that takes 54 00:06:13,860 --> 00:06:15,030 Toyota's printer. 55 00:06:15,240 --> 00:06:25,860 Now let's change this to yellow and this is going to print the statement in the Elif blah. 56 00:06:25,880 --> 00:06:36,790 Now if I say colored is now red if a live conditions at Fort the ends block get executed.