WEBVTT 00:00.550 --> 00:02.200 Hey Guys welcome to our new video. 00:02.200 --> 00:04.720 In this video let us talk about treatment. 00:04.960 --> 00:11.350 So if statement is used to execute a certain block of all depending on the condition we are giving if 00:11.350 --> 00:16.300 the condition is true we are going to perform a certain block of code and if the condition is false 00:16.390 --> 00:18.640 we are going to a home on the block of code. 00:18.670 --> 00:21.240 For example if I take a real life scenario. 00:21.310 --> 00:28.720 So I did a condition if traffic light is equals to read then we are going to stop is we can go. 00:28.870 --> 00:34.070 So you can see this is the basic condition and that's how we can use in our program. 00:34.210 --> 00:41.980 So before the link for us for for our for small program related to here I did very well as equals to 00:41.980 --> 00:42.650 18. 00:42.820 --> 00:50.800 And now I need to check a condition that is equal to 18 then I people whom I serve in block or I can 00:50.800 --> 00:52.140 use if statement. 00:52.240 --> 00:56.310 So all I need to do is if now I need to give my condition. 00:56.360 --> 01:01.920 So that is equal to eating. 01:02.090 --> 01:09.070 Now I'm using relational operator that means I'm using double equals two to check and compare each and 01:09.150 --> 01:15.690 even number and I need to use a colon after completing my condition and press enter. 01:15.790 --> 01:22.150 Now here you can see the indentation the gap between our initial line the initial margin and the current 01:22.210 --> 01:22.970 cursor. 01:23.080 --> 01:26.350 So this is the gap of four space by the form in Python. 01:26.470 --> 01:32.140 That means whatever lines of code we're going to write will be inside this particular if statement. 01:32.290 --> 01:33.750 And this will be in a group. 01:33.880 --> 01:41.060 So we have if the age is eating I'm going to print you on order not it does try to underscore. 01:41.200 --> 01:44.650 So all I have to do is write Python and then my filename. 01:44.710 --> 01:45.990 Don't forget to save the file. 01:46.000 --> 01:48.910 Otherwise they will get errors or they will not work. 01:49.060 --> 01:56.050 So here you can see the symbol ex-Nazi and if I click on control plus as you can see that's gone let 01:56.050 --> 01:57.110 me run this one. 01:57.250 --> 02:03.220 You can see the condition is true that means the composition of each and in are equal and that word 02:03.240 --> 02:04.950 squat inside the statement. 02:04.950 --> 02:11.380 That is if statement and executed a block of code so we can leave a lot of things you might be with 02:11.380 --> 02:15.640 us so being traffic light and check if that light is red. 02:15.700 --> 02:23.740 Then we have to stop and we can go negative my variable as light can give us something that is red and 02:23.750 --> 02:31.840 head is light is red and then we have to stop and all the kind of ideas if light is not good then we 02:31.840 --> 02:41.530 can go so right on the bar on up blues just use it and it has to be on the same margin of error and 02:41.530 --> 02:46.550 then press enter now the code that we are going to write that will be inside its condition. 02:46.690 --> 02:49.660 So all our boys brain go. 02:49.900 --> 02:54.520 So what I'm doing is I'm checking condition if light is equal to red. 02:54.520 --> 03:01.060 That means if the condition is true I'm going to stop and if the condition is false then this particular 03:01.150 --> 03:02.620 alarm will be second. 03:02.740 --> 03:09.970 That means I'm going inside the condition and if I save the file and try to execute this you can see 03:10.120 --> 03:15.490 either result of stop or let me take more examples so it will be better for you. 03:15.580 --> 03:21.760 Let me take an example with number system so we have the data available and check that if the value 03:21.760 --> 03:23.440 is positive or negative. 03:23.620 --> 03:29.880 So all we have to do is condition check if the values wasn't there and then check if the value was negative. 03:30.160 --> 03:35.510 So if x is greater than zero then we can remain positive. 03:35.620 --> 03:43.870 I can also be another condition that if X is less than zero then we can trade negative. 03:44.060 --> 03:47.990 So let me run this let me say and try to run this. 03:48.190 --> 03:55.980 You can say this was a day but instead of taking this I can use as if x is greater than zero then I'm 03:55.970 --> 03:59.800 going to print positive and I'm going to print negative. 03:59.920 --> 04:02.100 So if I run this one it's one of them. 04:02.350 --> 04:04.590 But what if I give up in July of 0. 04:04.840 --> 04:05.990 Let me test this out. 04:06.040 --> 04:08.950 And on this one you can see I'm getting a negative. 04:08.980 --> 04:10.460 So I have to fix this one. 04:10.570 --> 04:16.110 So if x is greater than or equal to zero then it is what again. 04:16.510 --> 04:23.740 So I hope no an assignment if statement and it's an X more after completing the if statement I'm going 04:23.740 --> 04:32.420 to write anything here will not be included in the blow off if it ends so if I write here as time now 04:32.700 --> 04:39.660 this statement on done has nothing to do with if it's and the condition that we are providing and if 04:39.660 --> 04:44.820 I try to run this you'll see that I'm going to break down every time if I tried. 04:44.880 --> 04:52.300 If I told them if I write anything it will not change Tuppence treatment I've done because it doesn't 04:52.300 --> 04:54.700 give a damn about our IF statement. 04:54.940 --> 05:00.210 So that means the block inside the core that is the indentation is really important. 05:00.400 --> 05:07.860 In other languages we use curly braces but in Python We use the pool symbol after completing a condition 05:08.140 --> 05:15.370 and then we use the indentation to fill this particular block of code is under this if condition and 05:15.370 --> 05:23.140 head this particular block or is under his statement in the next lecture we'll be also mixing some logical 05:23.140 --> 05:27.910 operators and we'll be using if as a nested IF ELSE. 05:27.910 --> 05:32.840 I hope you understand if statement and x and x see you in the next lecture.