1 00:00:00,150 --> 00:00:07,770 The use of if Elif and Elst block, so let us go for the Datalink, if Optative will be lighting one 2 00:00:07,770 --> 00:00:13,920 condition and then we're supposed to put one on hand, whenever we are putting a colon, then the next 3 00:00:13,920 --> 00:00:15,870 line will be coming with the indentation. 4 00:00:16,230 --> 00:00:21,330 That means in this particular indentation we are having one, two, three, four blank spaces and that 5 00:00:21,330 --> 00:00:26,730 will indicate that this particular statement, this particular block will be under that conditional. 6 00:00:26,730 --> 00:00:32,910 If so, when the condition will be true, that will be coming to this block or else if we are talking 7 00:00:32,910 --> 00:00:34,980 it else, if we are calling it as L.C. 8 00:00:34,980 --> 00:00:40,250 But it is e-life so different languages that have different syntax to write this one. 9 00:00:40,260 --> 00:00:47,640 So it is if there is an elusive RLC, we are putting another condition and then having one on here. 10 00:00:47,940 --> 00:00:49,680 The next block will get executed. 11 00:00:49,680 --> 00:00:55,530 When this particular condition will be true, uncontrol will be coming to the else block if the condition 12 00:00:55,890 --> 00:00:58,060 ignores the if statement is false. 13 00:00:58,920 --> 00:01:04,010 So when this particular condition is false as well as when the condition was false, then the content 14 00:01:04,340 --> 00:01:06,340 will be coming to this elif block. 15 00:01:06,630 --> 00:01:12,990 So here we are having one two conditions that they are connected with the end and then if the both conditions 16 00:01:12,990 --> 00:01:16,630 are true, then that will be coming to this block for execution. 17 00:01:16,650 --> 00:01:20,370 Otherwise the content will come to this block in this. 18 00:01:20,370 --> 00:01:27,390 If Elif and El's elephant else these blocks are optional, we may or may not give Elsley the last block 19 00:01:27,390 --> 00:01:29,330 after or else we cannot have the ELIF. 20 00:01:29,970 --> 00:01:35,940 But this if it's mandatory, if we write any conditional statement, if it's mandatory, but Elif and 21 00:01:35,940 --> 00:01:37,620 else they are not mandatory. 22 00:01:37,800 --> 00:01:44,190 We're here to abuse to elif blocks, but we can have multiple such but else we have a single block here. 23 00:01:44,280 --> 00:01:45,980 That means we cannot have anything else. 24 00:01:46,680 --> 00:01:48,450 So let us go for the execution. 25 00:01:48,450 --> 00:01:53,610 You can find that we are asking the age of a person and then using the input function. 26 00:01:53,610 --> 00:01:58,980 We are reading the age from the keyboard and then we are converting it to the integer and then it is 27 00:01:58,980 --> 00:02:00,930 getting assigned onto the edge. 28 00:02:01,500 --> 00:02:07,380 And then if it is less than five, then this condition, this particular statement is going to get printed 29 00:02:07,380 --> 00:02:09,120 as the condition is becoming true. 30 00:02:09,450 --> 00:02:11,660 So let us go for the execution you can find better. 31 00:02:12,150 --> 00:02:14,100 So I'm putting the age like four here. 32 00:02:14,430 --> 00:02:19,770 You see it is printing to Yoong because Ford is less than five excarnation is true. 33 00:02:19,770 --> 00:02:25,230 So control is coming down here and this part will remain on executed, unreachable. 34 00:02:26,010 --> 00:02:29,060 Next, if we go for the execution, if we put the values of five. 35 00:02:29,190 --> 00:02:29,970 Exactly. 36 00:02:30,480 --> 00:02:33,030 Then kindergarden is getting printed. 37 00:02:33,030 --> 00:02:37,590 So kindergarten is getting printed because this line is getting the control. 38 00:02:38,100 --> 00:02:41,100 Now, we shall put one H in between five to seventeen. 39 00:02:41,100 --> 00:02:43,050 So let us go for the ten here. 40 00:02:44,880 --> 00:02:50,900 Say, is he go to Fikret because then minus five is five, so that fight is getting printed. 41 00:02:51,120 --> 00:02:55,500 So control came in this block here, not we are going for the next one. 42 00:02:56,200 --> 00:03:02,420 So if we put the into here, if there is a 20, then it is going for go to college. 43 00:03:02,430 --> 00:03:03,670 It is going for go to college. 44 00:03:03,990 --> 00:03:09,920 So in this way, you are getting this idea that how this conditional statements are getting executed. 45 00:03:10,440 --> 00:03:15,300 So let us go for another example where you will be using that Nienstedt if that means one, if block 46 00:03:15,420 --> 00:03:16,890 within another outlet. 47 00:03:16,890 --> 00:03:23,430 If in this program we will input a number and check if the number is positive or negative or Gedo and 48 00:03:23,430 --> 00:03:27,780 display an appropriate message, this time you lose the nested. 49 00:03:27,780 --> 00:03:33,810 If so, at first we are asking the user to input a number and the number will be converted to the float 50 00:03:33,960 --> 00:03:36,360 type and then that will be assigned to the number. 51 00:03:36,870 --> 00:03:38,870 If not means then equal digital. 52 00:03:39,000 --> 00:03:40,980 That means the name is greater than equal digital. 53 00:03:41,310 --> 00:03:43,050 Then we are going for this operation. 54 00:03:43,500 --> 00:03:45,530 So when the number is greater than equal digital. 55 00:03:45,540 --> 00:03:49,950 So we are coming down to this block and here we are checking whether the number is zero or not. 56 00:03:50,220 --> 00:03:53,430 If the number is zero, we are printing this message gittel others. 57 00:03:53,430 --> 00:03:55,670 We are printing the message negative number. 58 00:03:56,010 --> 00:04:00,030 So if the condition is false, then contact will be coming directly to the sales block. 59 00:04:00,150 --> 00:04:02,940 And here the negative number printed here. 60 00:04:02,940 --> 00:04:08,210 You can find that this, if else block is within this indentation of the outer one. 61 00:04:08,460 --> 00:04:14,490 So that means when this condition is true, then control will be coming to this if else nested one. 62 00:04:14,970 --> 00:04:16,230 So it is our nested. 63 00:04:16,230 --> 00:04:22,250 If so, you are getting this idea that indentation is playing a very vital role in our python coding. 64 00:04:22,680 --> 00:04:25,670 So let me go for the execution here, putting the values at zero. 65 00:04:26,130 --> 00:04:30,710 So as a result of that num greater than equal to zero is getting through. 66 00:04:31,050 --> 00:04:37,500 So now it will come to this line number is going digital is through here because I put the value zero 67 00:04:37,770 --> 00:04:43,860 and then print zero zero has got printed rescored has been unreachable on executed. 68 00:04:44,340 --> 00:04:46,070 Let us go for another time execution. 69 00:04:46,080 --> 00:04:53,510 With the values of five, we can find that five is greater than to the conditions through five exclusively 70 00:04:53,520 --> 00:04:54,860 due to the condition is false. 71 00:04:54,890 --> 00:04:56,880 It is coming to this positive number here. 72 00:04:57,180 --> 00:04:58,710 So that's quite a positive number. 73 00:04:58,710 --> 00:04:59,990 String has got printed. 74 00:05:00,390 --> 00:05:06,120 So now if I go for this minus ten, you can find that negative number is getting printed because minus 75 00:05:06,120 --> 00:05:07,200 10 Gherardini collegial. 76 00:05:07,260 --> 00:05:08,330 The condition is false. 77 00:05:08,490 --> 00:05:13,680 So can you come to the L spot and the negative number will get printed. 78 00:05:14,100 --> 00:05:21,420 So in this way, we have demonstrated that how to use that if Elif and Ls block and what is negative 79 00:05:21,510 --> 00:05:24,460 and how to write that one with the proper indentation. 80 00:05:24,750 --> 00:05:25,980 Thanks for watching this video.