WEBVTT 00:00.630 --> 00:01.780 You guys will come back. 00:01.780 --> 00:07.770 Now let us continue the flow of IF statement in the previous example we understand what is if statement 00:07.830 --> 00:09.280 and all the blocks of code. 00:09.420 --> 00:11.140 But now let us take two things. 00:11.160 --> 00:18.270 Two important things first is how to use logical operators along with our IF statement to check different 00:18.270 --> 00:20.170 conditions at one go. 00:20.400 --> 00:25.430 And second thing is take input from user in real time liquidy problem. 00:25.620 --> 00:32.160 I need to take each as input from the user and then I need to check that if the user is created then 00:32.200 --> 00:35.260 in in less than twenty five then I have to perform. 00:35.260 --> 00:39.270 So the intent of all is I need to become something else. 00:39.300 --> 00:40.370 Solidest stock. 00:40.530 --> 00:47.100 So all I have to do is take a medieval age and then I can use my inverse function and ask user what 00:47.100 --> 00:47.910 is your range. 00:47.910 --> 00:54.020 Now remember it would be stored as string because we know that input functions are written on a string. 00:54.030 --> 00:58.400 So if I use that and those do that would be stored as string. 00:58.560 --> 01:01.850 So for that I need to use in function and type consta. 01:02.010 --> 01:05.250 So now my string will be converted into integer. 01:05.520 --> 01:11.360 And now I can use my logical operator to check two conditions along with IF statement. 01:11.580 --> 01:12.800 So if I use f.. 01:12.950 --> 01:17.860 Now the first condition is that it should be greater than equal to 18. 01:18.030 --> 01:25.950 And my second condition is it should be less than an equal to 25. 01:25.950 --> 01:31.470 Now here you can see I have used and operator that means both the condition has to be true. 01:31.800 --> 01:39.840 And if that happens I can print you a good Dougall and if so then condition doesn't follow. 01:39.840 --> 01:42.730 What I can do is I can remove this indentation. 01:42.780 --> 01:44.930 Go to the margin of IF and type. 01:45.060 --> 01:45.860 Else. 01:45.870 --> 01:48.810 And in this case I can insert in block of code. 01:48.990 --> 01:51.160 So now I've saved this particular file. 01:51.210 --> 01:56.820 You can see I have an input of it and then I'm taking two conditions and a definition is true. 01:56.820 --> 01:59.090 I'm going with this particular a print option. 01:59.250 --> 02:04.270 And if that is false then I'm going to block selecting that. 02:04.590 --> 02:07.300 Now it's asking me what is my age. 02:07.350 --> 02:08.660 You can see below. 02:08.790 --> 02:13.950 And if I tried that again and age 30 you can see I'm not alone. 02:14.280 --> 02:15.780 So this is a basic program. 02:15.840 --> 02:19.430 Now I think I need to talk about nested IF ELSE. 02:19.620 --> 02:21.760 So what is nested if it is. 02:21.780 --> 02:29.100 So when we talk about open condition they can follow another condition like if I'm digging age of 18 02:29.160 --> 02:34.830 and 25 I can also divide and take another condition inside this particular law. 02:35.040 --> 02:39.390 Like if it is 18 to 22 then I need to go home so fast. 02:39.630 --> 02:44.570 And from 20 to 25 I need to become a dentist so that can be followed. 02:44.580 --> 02:49.890 Inside this particular school for now I'll be digging a basic example that would be really interesting 02:49.890 --> 02:50.520 for you. 02:50.670 --> 02:56.650 So let us take a number from one user and then we need to check if the number is positive or negative. 02:56.850 --> 03:02.060 If the number is positive we need to check that it's even number or number. 03:02.220 --> 03:06.110 So that would be much interesting and you can understand that easily. 03:06.120 --> 03:12.400 So what I have to do is take a number as I am taking this as input. 03:12.600 --> 03:20.910 So I just need to come on and remember this will be a string find need to convert it into and that is 03:20.920 --> 03:22.320 my idea. 03:22.940 --> 03:28.280 And now one stock is all I have to do is bring the problem first for the booboos. 03:28.320 --> 03:31.080 I need to take positive negative. 03:31.140 --> 03:33.900 If that is positive I need to check or anything. 03:34.200 --> 03:37.360 So all I have to do is check about the positive case. 03:37.420 --> 03:44.960 So if it is greater than or equal to zero then I'm going to print positive as I'm going to print negative 03:45.710 --> 03:47.670 to say information we need to raise. 03:47.700 --> 03:53.620 If this is a positive number then we need to check if this is an even number or a number. 03:53.790 --> 04:00.990 That means I need to create our inside condition in my IF statement that is the nested IF so had I need 04:00.990 --> 04:03.270 to create a new condition that is. 04:03.830 --> 04:09.060 Now I need to check if I is divisible by 2 and giving a remainder of zero. 04:09.060 --> 04:10.630 So I can use more than less. 04:10.740 --> 04:18.750 So I more than two that means the remainder is equal to zero then I'm good to go. 04:18.750 --> 04:22.740 That means if the remainder is zero then the number is even. 04:22.760 --> 04:31.730 So all I have to do is print the condition and is that would be of course or no I've said my file. 04:31.740 --> 04:33.590 Let us run and check this. 04:33.770 --> 04:37.100 So all I have to do is type player I file. 04:37.110 --> 04:39.510 Now you answered asking my number. 04:39.510 --> 04:42.110 Let me give five and I'm done. 04:42.390 --> 04:45.180 It's a positive or I might quite distance again. 04:45.180 --> 04:48.410 And I if I give then that's a positive number. 04:48.590 --> 04:54.900 So I can see I've divided the conditions into two part that is to break down no problem for solving 04:54.960 --> 04:55.820 any problem. 04:55.950 --> 05:03.480 Break you down once I've checked my positive negative for the problem I've used uses nested if statements. 05:03.670 --> 05:06.800 Now you have to keep in mind that this is one block of all. 05:06.940 --> 05:13.930 And this is one block or when we enter this particular condition this is another block of all that is 05:13.930 --> 05:19.570 inside this condition and this is another block of or which is inside this its condition. 05:19.600 --> 05:21.650 So you have to be it off that. 05:22.090 --> 05:24.580 And you can see the indentation here. 05:24.580 --> 05:25.900 This is the False-Peace. 05:25.900 --> 05:27.340 These are the fools face. 05:27.490 --> 05:33.030 So that means this particular print statement is inside a nested IF statement. 05:33.040 --> 05:36.760 Now I hope you understand what is nested IF statement. 05:36.760 --> 05:42.730 You can also use another if statement inside this particular block and you can play with that. 05:42.730 --> 05:45.620 Now we need to understand if it is elif. 05:45.670 --> 05:46.400 Unless unless. 05:46.450 --> 05:47.390 What is that. 05:47.530 --> 05:53.130 So let me clear this out and start with a new program and think of a better example. 06:04.320 --> 06:05.780 So let us take a new. 06:05.850 --> 06:11.540 I have for a student and if someone picks it that means I have to send him to room number one. 06:11.550 --> 06:15.050 If someone picks B then I have to send them to room number two. 06:15.240 --> 06:20.260 If someone select the student told them not to send them to room number three and four then apples and 06:20.260 --> 06:26.040 then Gudel neighborhood so we can use is as safe as if it's condition not more time. 06:26.190 --> 06:30.880 So what we have to do is take input from a user about a student name. 06:30.990 --> 06:37.050 And if students need matches with all the false student available then we need to think a certain number 06:37.260 --> 06:41.430 as we need to say that invalid student name that is far from that. 06:41.610 --> 06:45.430 So all we have to start with is Steven import that is stupid. 06:45.630 --> 06:50.760 Now once you break the input you don't have to do anything since we need string as an input since we 06:50.760 --> 06:52.870 are playing with student name now. 06:52.920 --> 06:59.160 And now what I do is I need to check all the student name so as opposed to force to name a second one 06:59.160 --> 07:02.280 is Jonge carbonation and 420 Seany. 07:02.360 --> 07:04.800 So if it still is equal to. 07:05.010 --> 07:11.640 So we are checking that the student name that is stored in yesterday is equal to Shubha them we are 07:11.640 --> 07:16.690 providing certain instruction and I need to check for a student number two. 07:16.890 --> 07:24.240 So what I can use is is that I can only add one condition I need to check more conditions so I can use 07:24.340 --> 07:29.500 as if that is only the stoolie that is my second condition. 07:29.610 --> 07:35.100 And if the second condition is done then I need to send them to room number two. 07:35.190 --> 07:38.410 Now I also need to check out the third condition. 07:38.460 --> 07:42.130 So I need to go in as an add on the condition that is if 07:45.830 --> 07:53.270 an item for Commission which is Johnny So all that is done what if there is some as its name maybe or 07:53.300 --> 07:54.090 hardish. 07:54.240 --> 08:01.590 So what will I need to give a certain instruction to them so I can add is and that is will be. 08:01.800 --> 08:05.750 So now if I give you a brief I'm going to check if the student name is Shawn. 08:05.760 --> 08:12.450 I'm proceeding with through number one and these alternation would get scared and I would just print 08:12.450 --> 08:13.410 this one. 08:13.710 --> 08:17.500 If this condition is not true I'm going to the second condition. 08:17.670 --> 08:18.790 Check this out. 08:18.840 --> 08:21.660 And if this is true I'm going to bring about two. 08:21.660 --> 08:26.300 Number two if this is also not true I'm going to the third condition. 08:26.400 --> 08:31.800 Check this out if this is true then I'm going to number three and this is also not true. 08:31.800 --> 08:35.280 I went to the fault condition if this is also not true. 08:35.280 --> 08:36.580 I'm going to it is. 08:36.780 --> 08:42.640 So at any point of time as any condition is true I'm going to skip the section. 08:42.690 --> 08:46.600 That means if any condition is true then I'm good to go. 08:46.650 --> 08:55.260 And let us run this one a story that as I give Sharon instruction that proceed to rule number one. 08:55.400 --> 08:58.720 Let me try this out and if I score. 08:59.020 --> 09:02.490 Oh I got the error if I try again if I gave. 09:02.900 --> 09:07.100 When I want that that means any of the condition is true. 09:07.100 --> 09:12.640 I'm good to go and I need to skip all the other conditions and all these conditions are not true. 09:12.670 --> 09:15.410 Then I were to go with this condition. 09:15.520 --> 09:19.450 I hope you understand if nested IF is logical bar. 09:19.510 --> 09:22.640 And also LCF as if that is illness. 09:22.810 --> 09:27.220 And also remember that inundations are really important in Python. 09:27.310 --> 09:28.880 So you have to be careful. 09:29.080 --> 09:30.970 I hope you understand this lecture. 09:30.970 --> 09:32.200 Good to see your brain. 09:32.200 --> 09:34.500 See you in the next lecture.