WEBVTT

00:00.230 --> 00:00.920
Hello guys.

00:00.920 --> 00:03.560
So we are going to continue the discussion with respect to Python.

00:03.560 --> 00:07.640
And in our previous video we have already completed operators.

00:07.640 --> 00:13.040
And if you remember we have completed one complete section with respect to Python basics, uh, we understood

00:13.040 --> 00:15.020
about variables, data types and operators.

00:15.020 --> 00:20.450
Right now we are going to go towards an amazing new topic in Python, which is called as Control Flow.

00:20.450 --> 00:24.770
And in Control Flow, we are going to discuss about conditional statements and loops.

00:24.830 --> 00:28.970
In this video we are going to focus more on conditional statement.

00:28.970 --> 00:34.220
So here is the entire video outline what all things we are going to discuss.

00:34.220 --> 00:38.120
So first of all we are going to see introduction to Conditional statements.

00:38.120 --> 00:42.560
Then we'll go and understand what is if statement how to write if statement.

00:42.560 --> 00:44.000
With the help of Python.

00:44.000 --> 00:49.970
Then you have else statement, then you have else if statement then you have nested conditional statements.

00:50.000 --> 00:53.990
Along with this we will be implementing a lot of practical examples.

00:53.990 --> 00:54.230
We.

00:54.230 --> 00:58.100
I will be showing you multiple examples of real world use case examples.

00:58.100 --> 00:59.810
And then we'll try to solve that.

00:59.840 --> 01:04.730
Apart from that, The final thing is that we'll also see what are the common errors and what is the

01:04.730 --> 01:10.040
best practices that we should follow whenever we are using conditional statement with respect to if

01:10.070 --> 01:11.690
Elif and else.

01:11.780 --> 01:14.990
Now let's go ahead and let's start our coding.

01:14.990 --> 01:19.550
First of all, let's understand what is if statement right.

01:19.550 --> 01:22.340
And this is really important for you all to understand.

01:22.340 --> 01:27.860
And as I have always said before you start any Jupyter notebook, make sure you select the kernel with

01:27.860 --> 01:30.740
respect to the virtual environment that you have created.

01:30.770 --> 01:38.540
Now, if statement evaluates a condition and executes the block of code within it, if the condition

01:38.540 --> 01:40.730
is true, okay, what does this basically mean?

01:40.730 --> 01:44.240
Let's say that I am writing age is equal to 20, right?

01:44.240 --> 01:52.040
And now if I am writing an if statement after this, if we will be putting any conditions over here,

01:52.040 --> 01:55.520
let's say if I write, if age is greater than or equal to 20.

01:55.520 --> 01:57.200
So this is one of the condition.

01:57.230 --> 01:57.650
Right.

01:57.650 --> 02:01.990
So this if statement is going to evaluate this particular condition?

02:02.260 --> 02:07.330
And if it is true, right, it is going to go inside this particular block.

02:07.330 --> 02:07.810
Right.

02:07.810 --> 02:10.990
And obviously you know about indentation directly.

02:10.990 --> 02:14.080
You will be seeing that will be able to write the code inside the block.

02:14.080 --> 02:16.420
So here I will go ahead and write, print.

02:17.260 --> 02:21.070
Um, let's say that uh, I will go ahead and write age 18.

02:21.070 --> 02:25.330
And if the age is greater than or equal to 18 okay.

02:25.360 --> 02:27.280
And here I will go ahead and write 20.

02:27.310 --> 02:27.880
Okay.

02:28.000 --> 02:37.120
Then I will say that, hey, uh, you are allowed to vote in the elections, right?

02:37.120 --> 02:38.350
Something like this.

02:38.380 --> 02:39.670
Vote in the elections.

02:39.670 --> 02:42.160
So here you can probably see the output.

02:42.160 --> 02:44.470
You are allowed to vote in the elections.

02:44.470 --> 02:45.910
What does this basically mean?

02:46.000 --> 02:52.390
When I started my if statement, first of all the condition that I have written it, this will get evaluated.

02:52.390 --> 02:58.660
And obviously here you can see the age is greater than or equal to 80 because I have assigned the age

02:58.660 --> 03:01.420
variable is equal to 20 right now.

03:01.420 --> 03:06.160
Since this is greater than or equal to 18, you will be able to see that this entire condition will

03:06.160 --> 03:06.880
become true.

03:06.910 --> 03:08.620
This entire condition will become true.

03:08.620 --> 03:11.590
So it will go ahead and execute this particular statement.

03:11.620 --> 03:12.070
Right.

03:12.070 --> 03:16.870
And this is a very simple way of understanding if statement.

03:16.900 --> 03:21.250
Let me repeat again a if statement evaluates a condition.

03:21.250 --> 03:27.670
So this is my condition and it executes the block of code within it if the condition is true.

03:27.670 --> 03:29.410
So right now this condition is true.

03:29.410 --> 03:32.170
So that is why it is basically getting executed.

03:32.170 --> 03:34.300
How do I say this condition is true or not.

03:34.300 --> 03:40.330
If I just go and execute in my new cell and if I see age is greater than or equal to 18, this is true.

03:40.330 --> 03:43.900
So if true, I am going to go inside this particular block.

03:43.900 --> 03:45.910
So this was about if statement.

03:45.940 --> 03:47.980
Don't worry we will be seeing a lot of example.

03:48.010 --> 03:54.280
Now let me go ahead and show you the another uh conditional statement which we basically say is else

03:54.310 --> 03:55.210
right now.

03:55.210 --> 03:57.100
What exactly is else okay.

03:57.760 --> 04:02.250
Uh, to define else, I would like to, uh, probably talk about this.

04:02.280 --> 04:02.640
Okay.

04:02.670 --> 04:05.670
And let me just go ahead and write a comment over here again.

04:05.700 --> 04:13.260
The else statement executes a block of code if the condition in the if statement is false.

04:13.290 --> 04:14.430
What does this mean?

04:14.430 --> 04:19.380
That if this statement is false, it is not going to go inside this block.

04:19.380 --> 04:19.860
Right?

04:19.860 --> 04:23.940
So is there a way that I can probably move it into another block.

04:23.940 --> 04:24.420
Right.

04:24.420 --> 04:27.690
So for that we will be specifically using else statement.

04:27.690 --> 04:30.330
So let us go ahead and see one more example.

04:31.470 --> 04:34.590
So guys now let's go ahead and see this else statement.

04:34.590 --> 04:35.700
And how does it work.

04:35.730 --> 04:39.030
Okay let me just go ahead and write.

04:39.120 --> 04:42.450
Age is equal to 16 okay.

04:42.540 --> 04:45.690
And now you know the condition if you really want to vote.

04:45.720 --> 04:45.990
Right.

04:46.020 --> 04:47.730
So what is the condition that I have to write.

04:47.760 --> 04:51.300
If age is greater than or equal to 18 right.

04:51.420 --> 05:02.340
Then I can go ahead and print something like you are you are eligible for voting.

05:02.370 --> 05:05.040
Okay, so this is my statement that I have written, right.

05:05.430 --> 05:07.860
Now let's let's go ahead and execute this.

05:07.860 --> 05:08.460
Right now.

05:08.460 --> 05:12.000
When I'm executing this, you can see that nothing is getting printed.

05:12.000 --> 05:15.990
The reason is very simple because this statement has become false.

05:16.020 --> 05:16.410
Right.

05:16.440 --> 05:19.050
And so you are actually coming outside the block.

05:19.050 --> 05:20.400
Nothing is getting printed.

05:20.400 --> 05:26.400
But let's say I want to handle for this age in a separate way within this if clause.

05:26.430 --> 05:26.910
Right.

05:26.910 --> 05:33.600
So what I can do, I can again go ahead and write else clause right now inside this else clause I will

05:33.600 --> 05:40.770
probably say print you are a minor okay.

05:40.770 --> 05:42.420
So this will be my else block.

05:42.420 --> 05:44.430
Now what will happen if I execute this?

05:44.460 --> 05:49.470
You'll be seeing that if this is false, what it is going to do by default, it is going to jump into

05:49.470 --> 05:50.490
this particular block.

05:50.490 --> 05:50.850
Right.

05:50.880 --> 05:53.280
Because this is what my else condition is, right?

05:53.280 --> 05:54.960
The default condition at the end.

05:54.990 --> 05:55.470
Right?

05:55.500 --> 06:00.690
If nothing is getting satisfied, just go and jump to the last else block and display this.

06:00.690 --> 06:05.090
So once I'm executing this, you'll be able to see that here you are getting an answer.

06:05.090 --> 06:05.900
You are a minor.

06:05.900 --> 06:09.050
So this became false after this basically became false.

06:09.230 --> 06:10.790
It is going to the else block again.

06:10.790 --> 06:16.670
Let me repeat the else statement executes a block of code if the condition in the if statement is false.

06:16.700 --> 06:19.640
Okay, so here you can probably see this okay.

06:19.670 --> 06:26.420
Now let me just go ahead and go ahead with the next conditional statement which is called as Elif statement.

06:26.450 --> 06:26.960
Okay.

06:26.990 --> 06:33.260
Now with respect to the Elif statement, uh, if I really want to give a smaller definition for this.

06:33.290 --> 06:33.560
What?

06:33.680 --> 06:36.020
Okay, what exactly is an if statement?

06:36.050 --> 06:40.640
Now, this Elif statement allows you to check multiple condition.

06:40.640 --> 06:43.190
It stands for else if.

06:43.220 --> 06:44.960
Okay, that is the reason we say Elif.

06:44.990 --> 06:46.160
Elif statement is there.

06:46.160 --> 06:49.220
But if we go ahead and see the full form, it is nothing but else.

06:49.220 --> 06:50.090
If okay?

06:50.090 --> 06:52.850
And it allows you to check for multiple condition.

06:52.880 --> 06:58.280
Okay, now let me just go ahead and probably put some points over here.

06:58.610 --> 07:00.890
Let's say I'll show you some example.

07:00.890 --> 07:03.180
If I go ahead and write, age is equal to 20.

07:03.210 --> 07:03.660
Okay.

07:03.690 --> 07:04.920
Now let me go ahead and write.

07:04.950 --> 07:08.430
If age is less than 13.

07:08.580 --> 07:09.090
Okay.

07:09.690 --> 07:11.370
I'm putting some kind of condition over here.

07:11.400 --> 07:16.140
Any condition you can put, you can go ahead and put an end condition or condition, whatever condition

07:16.140 --> 07:16.500
you want.

07:16.530 --> 07:19.020
So any conditional statements, you can write it over here.

07:19.290 --> 07:23.460
Um, you know, and obviously you have seen this kind of statements, right?

07:23.460 --> 07:26.100
Where I am actually putting some kind of conditions over here.

07:26.130 --> 07:26.550
Right?

07:26.640 --> 07:28.680
Uh, anything you can actually put over there.

07:28.710 --> 07:35.100
Now, if I go ahead and write print, if age is less than 13, I will say, hey, you are a child.

07:35.130 --> 07:35.370
Okay?

07:35.400 --> 07:36.330
You are a child.

07:36.570 --> 07:38.970
Now I want to check for other condition.

07:39.000 --> 07:39.330
Also.

07:39.330 --> 07:41.130
Let me go ahead and write Elif.

07:41.130 --> 07:44.070
Now, Elif, age is less than 18.

07:44.100 --> 07:47.340
Okay, if the if the age is less than 18, then I will go ahead and say.

07:47.340 --> 07:48.060
Print.

07:48.510 --> 07:50.220
You are a teenager.

07:50.550 --> 07:53.850
Okay, you are a teenager, right?

07:53.850 --> 07:55.860
And then I will go ahead and write.

07:55.890 --> 07:56.580
Else.

07:56.580 --> 07:58.590
Finally, the else statement.

07:58.590 --> 08:02.660
By default, this will get if none of this condition is basically becoming true.

08:02.690 --> 08:04.760
This will get executed then.

08:04.760 --> 08:11.030
If I go ahead and write over here print, I will say, hey, you are an adult, okay?

08:11.030 --> 08:13.850
And now if I go ahead and execute it, what will happen?

08:13.850 --> 08:18.170
Which part will get basically executed, whether this or this or this.

08:18.200 --> 08:18.590
Right.

08:18.590 --> 08:23.990
So here you can probably see if I go ahead and execute you'll be able to see, hey, you are an adult

08:24.020 --> 08:24.740
right now.

08:24.740 --> 08:28.730
If I go ahead and write 17 as my age.

08:28.760 --> 08:29.180
Right.

08:29.180 --> 08:33.680
So first condition over here you can see age is less than 13, which is obviously false.

08:33.680 --> 08:34.910
It will go to the next one.

08:34.940 --> 08:39.620
Else if it is not going to check multiple condition if else if age is equal to 18.

08:39.650 --> 08:43.580
Now here it is going to be true and this is what it is going to get displayed right.

08:43.580 --> 08:46.700
So here you can see you are a teenager right.

08:47.000 --> 08:52.130
So this actually gives you an idea how this Elif basically works.

08:52.130 --> 08:52.400
Right.

08:52.400 --> 08:55.010
And Elif allows you to check multiple conditions.

08:55.040 --> 09:02.350
Right now, there may be scenario where I really want to use nested conditional statement.

09:02.350 --> 09:05.170
And this is what we are going to discuss about okay.

09:05.200 --> 09:09.130
Nested conditional statements.

09:10.390 --> 09:14.620
Conditional statements right now nested conditional statement.

09:14.650 --> 09:17.230
What all things you can basically do okay.

09:18.130 --> 09:26.110
We can use the combination of if else if or else inside the block like let's say inside this if clause

09:26.110 --> 09:27.460
I can write another if clause.

09:27.490 --> 09:27.910
Right.

09:27.910 --> 09:31.150
So here let me just go ahead and write this particular comment for you.

09:31.180 --> 09:40.240
You can place one or more if Elif or else statement inside another if Elif or else statement to create

09:40.300 --> 09:41.980
a nested conditional statement.

09:42.010 --> 09:48.940
Okay, now let's say, uh, I will just give you some of the examples over here to make you understand,

09:49.090 --> 09:49.990
uh, what?

09:50.020 --> 09:55.750
Uh, like let's say I want to probably I will give you a number number.

09:55.840 --> 10:02.140
You need to tell me whether it is even or odd or negative.

10:02.170 --> 10:02.710
Okay.

10:02.860 --> 10:04.090
Something like this.

10:04.120 --> 10:05.770
These are my three conditions.

10:05.800 --> 10:06.250
Okay.

10:06.280 --> 10:07.900
Let's say I have given my number.

10:07.900 --> 10:10.210
So let me go ahead and write input.

10:10.540 --> 10:11.020
Okay.

10:11.020 --> 10:13.000
So first of all I will define my number.

10:13.030 --> 10:14.260
I will use int.

10:14.260 --> 10:16.360
And then here I'm going to use input.

10:16.360 --> 10:19.300
And here I'm going to probably say enter the number.

10:19.330 --> 10:19.780
Okay.

10:19.810 --> 10:21.760
I will go ahead and enter the number.

10:21.820 --> 10:26.560
Now my first condition will be that I will go ahead and check for positive and negative number.

10:26.560 --> 10:30.340
So if I go ahead and write if number is greater than or equal to zero, sorry.

10:30.340 --> 10:33.760
If it is greater than zero, then I can probably.

10:33.760 --> 10:35.530
Okay, let me just go ahead and write.

10:35.560 --> 10:37.960
Then I can probably go ahead and print.

10:38.110 --> 10:44.080
The number is the number is positive right.

10:44.080 --> 10:47.500
So here you will be able to see that I am printing this okay.

10:47.530 --> 10:51.790
Now the next condition is that I need to check whether this number is even or odd.

10:51.820 --> 10:52.150
Right.

10:52.180 --> 10:56.470
Now in order to probably check, I may write any numerical conditions over here.

10:56.500 --> 11:00.160
If number I mean I will try to use any operators.

11:00.160 --> 11:00.370
Right.

11:00.370 --> 11:02.490
If number Modulus of two.

11:02.520 --> 11:06.960
Modulus of two basically means if the remainder is equal to zero, that basically indicates that.

11:06.960 --> 11:09.000
Obviously this is an even number.

11:09.000 --> 11:15.780
So here I'm going to print the number is even right.

11:15.780 --> 11:21.360
So here you can see the number is even else I'm going to probably print.

11:23.130 --> 11:27.210
The number is odd okay.

11:27.210 --> 11:29.490
So here you can see what I have actually done.

11:29.490 --> 11:35.550
If this if this gets solved that basically means we are going to say that hey the number is even.

11:35.550 --> 11:40.170
But if this is not true, then it will go to the else block saying that the number is odd.

11:40.170 --> 11:44.040
So what is basically happening inside an if condition?

11:44.040 --> 11:46.740
I have written another if condition along with else block.

11:46.740 --> 11:52.140
So this is what nested nested uh nested uh conditional statement means.

11:52.140 --> 11:55.950
Right now there is also one more thing for this if block.

11:55.950 --> 11:57.450
Also for the outer if block.

11:57.450 --> 12:00.900
Also I can again write an else condition saying that else.

12:00.900 --> 12:03.120
And this time I will go ahead and print.

12:03.120 --> 12:08.070
The number is the number is negative okay.

12:08.820 --> 12:14.040
Or a better way will be that if I'm entering the number, I will just go ahead and write greater than

12:14.070 --> 12:14.670
zero.

12:14.700 --> 12:15.210
Okay.

12:15.240 --> 12:19.980
And here in the else condition I will go ahead and write is zero or negative.

12:20.010 --> 12:20.610
Okay.

12:20.910 --> 12:24.060
Now see this is what nested conditional statement means.

12:24.060 --> 12:29.400
You can place one or if else or if else or else if or.

12:29.400 --> 12:34.920
Sorry Elif this kind of statements within another if clause or Elif clause.

12:34.950 --> 12:39.420
Okay similarly you can write another Elif clause over here wherever you specifically want, but the

12:39.420 --> 12:41.310
order will be the same thing, right?

12:41.310 --> 12:45.540
You need to probably make sure that you manage all the indentation part.

12:45.570 --> 12:49.800
If you are not managing the indentation part, then you may get an error.

12:49.830 --> 12:52.230
Okay, so here you go over here.

12:52.230 --> 12:58.110
And now if I go ahead and execute this you'll be able to see it is asking for me for a number.

12:58.110 --> 13:01.500
If I go ahead and write 12 I'll go ahead and press enter.

13:01.500 --> 13:05.060
So here you can see the number is positive and number is also even.

13:05.090 --> 13:05.450
Okay.

13:05.480 --> 13:07.070
Now again let me just go ahead and execute.

13:07.070 --> 13:07.430
This time.

13:07.430 --> 13:11.900
If I give 11 you will be able to see number is positive but the number is odd.

13:11.930 --> 13:14.450
The else part has got executed over here.

13:14.480 --> 13:16.490
Now again if I go ahead and execute it.

13:16.490 --> 13:18.410
And if I go ahead and write minus one.

13:18.410 --> 13:23.180
So here you can see the number is zero or negative which is basically going to the else block.

13:23.180 --> 13:23.570
Right.

13:23.600 --> 13:25.160
Why this is going to the else block.

13:25.160 --> 13:27.110
Because I have given the number as minus one.

13:27.110 --> 13:31.460
Now this is going to be false and it is just going to jump to the else block.

13:31.460 --> 13:31.880
Right.

13:31.910 --> 13:36.680
So I hope you are able to understand this in a amazing way.

13:36.800 --> 13:40.880
Uh, you got an idea with respect to if else if else.

13:40.880 --> 13:44.870
And also you got an idea with respect to the nested conditional statement.

13:44.900 --> 13:48.500
Now let us see some very important use cases.

13:48.500 --> 13:54.560
And, uh, I'll just say that, uh, some practical examples that we are going to probably discuss.

13:54.590 --> 13:55.100
Okay.

13:55.130 --> 14:00.320
See, the errors can only happen when you are not doing the proper indentation over here.

14:00.320 --> 14:00.530
Right?

14:00.560 --> 14:05.240
If the indentation is basically done in a proper way, then you should be able to write this if else

14:05.240 --> 14:07.040
block in a very efficient way.

14:07.070 --> 14:11.090
Okay, now first practical example that I'm actually going to give you.

14:11.120 --> 14:11.690
Okay.

14:12.500 --> 14:19.310
You need to determine if a year is a leap year.

14:19.340 --> 14:21.140
What does leap year basically mean.

14:21.170 --> 14:23.570
Any year that is divided by four.

14:23.600 --> 14:27.920
If the remainder is zero, that that basically means it is a leap year.

14:27.950 --> 14:32.570
Using nested conditional statement.

14:32.600 --> 14:36.710
Now you can pause the video and you can start writing this right.

14:36.710 --> 14:41.660
And you can see what it will probably give you and what it will not give you.

14:41.690 --> 14:42.200
Okay.

14:42.230 --> 14:44.570
Now let me just go ahead and write this.

14:44.570 --> 14:47.060
So first of all, I will go ahead and write here.

14:47.060 --> 14:49.250
And I will give this as an input.

14:49.280 --> 14:49.820
Okay.

14:49.850 --> 14:52.550
And let me just go ahead and say enter the year.

14:52.580 --> 14:53.180
Okay.

14:53.780 --> 14:54.800
Enter the year.

14:54.980 --> 14:55.550
Okay.

14:55.970 --> 15:00.800
Now next thing if I will start my condition.

15:00.800 --> 15:07.680
If year modulus for right is double equal to zero right.

15:07.680 --> 15:10.200
So here see understand this particular condition.

15:10.200 --> 15:14.610
Also if your modulus for is equal to zero right then what I will do.

15:14.640 --> 15:15.000
See here.

15:15.000 --> 15:16.830
Also I can also write like this.

15:17.130 --> 15:23.430
If number percentile uh modulus two is equal to double equal to zero I have used one additional bracket.

15:23.430 --> 15:26.580
So let me just remove this if you are getting confused with this okay.

15:26.610 --> 15:32.370
If it is double equal to zero then I will also go ahead and put one more condition.

15:32.370 --> 15:36.930
If here modulo 100 is double equal to zero right.

15:36.960 --> 15:39.240
So here I have used two nested if else clause.

15:39.270 --> 15:39.870
Right.

15:39.870 --> 15:41.400
And if here.

15:43.410 --> 15:47.580
Uh modulus 400 double equal to zero okay.

15:47.610 --> 15:50.790
So see how many nested if else we have actually done.

15:50.820 --> 15:51.390
Okay.

15:51.420 --> 15:57.060
Now if this condition is basically if this all three condition is basically true, which is specifically

15:57.060 --> 16:02.380
for the leap year, what I'm actually going to do, I'm going to go ahead and write print This year.

16:02.380 --> 16:04.720
Whatever I've actually given, right?

16:04.720 --> 16:09.370
Whatever year I've actually given is a leap year.

16:09.400 --> 16:11.500
Okay is a leap year.

16:11.500 --> 16:14.350
So here is how I'm actually using the print statement.

16:14.380 --> 16:17.980
Okay, I will take one more session with respect to the print formatting.

16:18.010 --> 16:18.490
Okay.

16:18.520 --> 16:20.860
Are there different different ways of print formatting.

16:20.860 --> 16:22.300
So print year is a leap year.

16:22.330 --> 16:22.780
Okay.

16:22.810 --> 16:25.240
Then I will go ahead and write in the else block.

16:25.240 --> 16:26.980
What if this is not true.

16:27.010 --> 16:29.050
What if this two statements are true?

16:29.050 --> 16:30.550
But this is not true, right?

16:30.580 --> 16:32.380
Then I will go ahead and print.

16:32.410 --> 16:35.230
This year is not a leap year, right?

16:35.260 --> 16:39.910
The same year is not a leap year.

16:40.090 --> 16:40.660
Okay.

16:40.660 --> 16:43.120
So here you can probably see this okay.

16:43.150 --> 16:46.780
Then let's say fine for this.

16:46.810 --> 16:49.120
If if it is false I'm handling it over here.

16:49.120 --> 16:50.080
But what about this.

16:50.110 --> 16:53.110
If so for this we will write another else statement.

16:53.140 --> 16:53.680
Okay.

16:53.680 --> 17:01.150
And here I will also give one more condition saying that hey print year.

17:02.500 --> 17:10.180
And if this is also true, if your 100 model is 100 is equal to zero, I will be saying that hey, here

17:10.180 --> 17:11.530
is a leap year.

17:12.520 --> 17:14.920
Okay is a leap year.

17:15.340 --> 17:19.720
I'm just trying to write it in a complex if else condition.

17:19.720 --> 17:25.090
And finally, if this condition is also true in the else block, I will go ahead and basically go ahead

17:25.090 --> 17:29.200
and write print, print.

17:31.420 --> 17:32.380
Here.

17:35.380 --> 17:38.230
Is not a leap year okay.

17:38.260 --> 17:39.010
Done.

17:39.010 --> 17:44.440
So here you can basically see that if this condition is true then also we know that it is a leap year.

17:44.440 --> 17:47.170
So for that further conditions we are applying this one.

17:47.170 --> 17:49.120
Then again further we are applying this one.

17:49.120 --> 17:52.750
But if this is also not true then we also need to handle in the else block.

17:52.750 --> 17:55.060
Right now let me just go ahead and try it out.

17:55.060 --> 17:56.680
So here I'm just going to execute it.

17:56.680 --> 17:59.530
And let's say I go ahead and write 2022.

17:59.560 --> 18:04.210
Now obviously this will be uh, not a leap year, but let's execute this.

18:04.210 --> 18:07.390
And here you can see 2022 is not a leap year, right?

18:07.420 --> 18:09.160
If I go ahead and execute it again.

18:09.160 --> 18:11.350
So let's go ahead and see 2024.

18:11.380 --> 18:15.880
If I go ahead and execute over here 2024 is a leap year right now.

18:15.880 --> 18:18.760
So this is one of the good amazing practical example.

18:18.760 --> 18:22.960
Now what I'm going to do is that I'm going to give you more assignments as we go ahead.

18:22.990 --> 18:23.830
Right.

18:24.400 --> 18:28.690
Uh, we need to also understand what are the common errors and mistakes that we usually do.

18:28.690 --> 18:33.790
If you have not written colon, if the indentation part is not done properly, then obviously this will

18:33.790 --> 18:36.190
be a problem right now.

18:36.190 --> 18:41.650
Uh, let me give you some of the assignments, which you should definitely do.

18:41.680 --> 18:42.190
Okay.

18:42.220 --> 18:50.470
One is, uh, please try to create a simple calculator a simple calculator calculator.

18:50.560 --> 18:56.920
And inside this simple calculator program you need to take an input from the user, perform different

18:56.920 --> 19:03.300
different operations, what kind of operations you need to do if it is plus then by using if else condition,

19:03.300 --> 19:04.440
you really need to do it.

19:04.440 --> 19:06.810
So here I will just be.

19:06.840 --> 19:12.450
Please make sure that first of all, before I show you the solution, you try to write the code from

19:12.450 --> 19:12.870
your side.

19:12.900 --> 19:21.270
Okay, so here you can see, uh, I will just go ahead and update this just a second.

19:24.510 --> 19:25.200
Okay.

19:26.340 --> 19:29.190
So here you can probably see I have used float input.

19:29.190 --> 19:30.000
Enter the first number.

19:30.030 --> 19:35.280
Second number operation is either you can upload plus minus star or division.

19:35.280 --> 19:37.170
You can also use modulus if you want.

19:37.170 --> 19:38.970
And then I have written all this condition.

19:39.000 --> 19:40.170
It's operation is equal to plus.

19:40.170 --> 19:46.020
Then result num plus one this this this else you'll be also able to see the nested elsif is also there.

19:46.050 --> 19:48.960
Else if if number is not equal to zero right.

19:48.990 --> 19:50.190
Just go ahead and see this.

19:50.220 --> 19:53.700
Whatever things we have discussed till now, I think you should be able to understand it.

19:53.730 --> 19:54.150
Okay.

19:54.180 --> 19:55.920
So let me just go ahead and execute it.

19:55.920 --> 19:57.600
Let's say 12.

19:57.630 --> 20:00.120
I'll go ahead and press 24.

20:00.150 --> 20:01.560
I'll go ahead and press enter.

20:01.560 --> 20:03.710
And let's say I want to do plus operation.

20:03.710 --> 20:06.860
So here you can see 36.0 okay.

20:06.950 --> 20:08.930
So try to do this.

20:08.930 --> 20:12.830
Uh one more example that I really want to give it to you okay.

20:12.920 --> 20:16.550
Determine the ticket price based on the age.

20:17.270 --> 20:17.570
Okay.

20:17.600 --> 20:19.670
So this will be another one example.

20:19.670 --> 20:23.960
So I have multiple examples but definitely do try it from your side.

20:23.960 --> 20:28.280
So I'm just putting so that you will be able to practice it okay.

20:28.580 --> 20:30.650
So here you can see enter your age.

20:30.680 --> 20:31.400
Are you a student.

20:31.430 --> 20:32.150
Yes or no.

20:32.150 --> 20:37.850
So if you are probably saying yes then you will be seeing yes over here.

20:37.880 --> 20:39.680
So here are some of the condition.

20:39.680 --> 20:41.840
If age is less than five, price is free.

20:41.870 --> 20:46.850
Else if is age is less than 12, price is $10 if age is less than 17.

20:46.850 --> 20:50.300
And if the student if it is a student, then price is $12.

20:50.330 --> 20:54.350
Else if $15, then just try to go through this okay?

20:54.380 --> 20:56.780
And then you will be able to understand it.

20:56.780 --> 20:59.780
So I hope you were able to understand this video.

20:59.900 --> 21:01.160
This was it from my side.

21:01.160 --> 21:02.630
I will see you all in the next video.

21:02.660 --> 21:03.050
Thank you.
