Hello, everyone.
So in this particular session, we will learn about if conditions, but before learning about if conditions
and knowing what exactly they are, we need to understand why the village required.
So let us look at this piece of code there.
I have value of geek as baking, which means that cake is baking.
So we print the message that he is making.
After that, we will print a simple message as good bye.
Now, when I run this, I get the message, cake is baking and goodbye.
Now, let's say we have a situation where cake might not really be baking.
So in that case, the value of cake will be.
Not picking, OK, so we in that particular case, we want to bring cake is not making any sort of cake
is OK.
So this is the dessert for us.
Now, let us say we want to have both of these cases in our piece of code.
Now, what will we do to have both of these considered?
So in that case, we will be using if conditions, the if condition allows us to have responses to different
scenarios or different situations which occur, why the program is running.
So let us see if the value of variable cake is baking.
Then I want to bring that cake is baking and the value when it is not baking, then I want to bring
that cake is not baking.
So I want to be these two options.
So in that situation I can use if conditions.
So let us suppose to that how we will write the if condition.
So to write the if condition, we will have to first of all see if.
And then we write the condition, so the condition is.
Greg.
Is equivalent to.
Making.
Now, consider this.
The value of Kek has to be exactly breaking if I write Capital B, then this will not be equal to this
because both of these strings are different.
So we need to keep it as making.
Then the apply of Golan, which means that the if condition is starting so doesn't exist if.
Followed by the condition which we are trying to evaluate.
Then fallen and then automatically, when you hit enter, you get this indentation.
In case you do not get an indentation, you can press up and get this indentation and the whole piece
of gold, which will be hot, which will be a part of this if condition would be written after this
indentation.
So let us see if Gache is baking, then we want to print.
OK, and speaking.
OK, and.
This is a simple if condition.
OK, after that, we want to print.
Good bye.
So when we say cake is baking, so it will, first of all, evaluate this particular condition, it
will check if the value of cake is equivalent to this baking.
If the response of this condition evaluation is true, then only it will run whatever piece of food
would be present after this indentation, we could have more piece of code here, say like print.
He.
And many we could have any number of lines of code present here.
And when I do not have this emendations, this means that this is outside this if condition.
So no matter the cake is equivalent to baking or not, this line of code would anyhow be printed.
This would run in any situation, only these lines of code, which are a part of this if condition will
be run, if this key value, the value of the variable cake is equal to baking.
So let us try that.
So here you can see.
So the value of geek's all letters.
Run this one, so here the value of cake is equal to baking.
Now I am running this so you can see that it is giving this value cake is baking, cake is and then
goodbye.
Now let us see how these conditions work, OK?
So here we can see that the control flow will come to this if condition.
And once the controlled flow comes to this condition, it will evaluate the condition which is present
to you now after this evaluation.
If there is any Nortman or non-zero value, it will correspond to two, and if the value is zero or
null, it will be false.
OK, now here we evaluate this particular condition and once we evaluate this condition, if the value
is false, then the false expression would be run and the value is true, then the true expression would
be done and after that it will go to the next statement.
This is the condition of if so, if the condition is true, then this would be wrong.
And if it is false, then we will have to provide the LS condition.
Now what is its condition?
So we see this that this is equivalent to making this condition is true.
Then it runs this piece of wood.
Now what.
This cake is not equal to making so us run this piece of code.
So once I run this, the value of geek has been updated law making.
So now if I run this piece of code, it will not show me any messages because I have not given any is
condition, but it will bring good barbarically now in case we want to provide a false condition.
Also, we want to provide a response to the false criteria.
In that case, we will write is.
What Colin and whatever piece of code we want to done as a part of is we will write in below it.
So let us say we want to run this only.
So let me put this here.
So now this line of code will run.
If this condition is not to say the condition is true, it will run this piece of code and if the condition
is not true, it will run this piece of good.
So let us run this again.
So now you can see we get the value Qik is not making.
And then good bye.
Good bye.
Right.
This is one scenario now we can have a simple if.
Apart from that, we can have if and is both.
That is one more condition where we can have if if I live and it's so, let us see how that works out.
So we have a condition, if it's condition, if anything else.
Now, let us see what these Chinna.
Now, if you see this so first of all, it will verify this if condition.
If the condition is true, then it will run the good luck, which is a part of this if condition, and
then it will directly go to the end of the if condition.
Oh, I'm Randy.
Next, lines of code.
Now, if this if condition is not true, then it will go to the next ayliffe expression, so it will
evaluate this expression.
Now if this expression is true, it will run this of block and then go to the end of it.
Now, in case this is not true, then it will evaluate the next condition.
If next condition is true, it will run that particular good luck.
If it is not true, then it will go to the very next is good luck.
If none of these if elif the codes are true then it will go to the end.
Good luck and simply run.
This is good.
I run this one and stop or go to the next line of food.
Now, let us see this in action, so we have this.
So let's do it this way.
So we have if Jake is making if it is not breaking, then we are doing this now.
Let us see.
If he is equivalent to baking, then this cake is making now Elif.
Now, this is another if kind of a condition, so we need to give a condition here, if they don't give
a condition, will not rule.
So we need to give a condition sick.
Is equivalent to.
Beit.
Then you want this particular piece of food to be run, so we want to bring.
Then.
We can have another day, live condition, we can have any number of live conditions here, so let us
take.
So we say no gig today, so let us try different scenarios here by changing the values of.
So first of all, if the value of cake is baking.
And we've done this so we get results as.
Cake is baking, cake is, and then the final goodbye in case the value of cake is baked.
We get cake is not baked, a cake is not baking.
Now, see here, the give baked with a small V. So idiotically went to the ends condition.
So what happened here?
Is it checked if the key value is baking.
So it was not true.
So it went to the next live condition.
A. The geek's value is baked with a capital B..
Now, this is not true.
So it went to the next Ayliffe condition here to check if it is equivalent to don't like.
So this is not equal to go.
No, don't like.
So it went to the is condition and granted finally now in case the value is capital B capital be baked.
So now what will happen is it will bring cake is baked already and then it will train the next lines
of code.
And here if we have a don't like then it will just bring the message today and then goodbye.
So this is about if conditions they are discussed about the if ayliffe conditions, we can also create
misted if conditions which would have further indentation now while creating the indentation, one has
to make sure that they do not get confused.
So let us dry how we can create nested indentation you.
So here we have a if condition, so let us try to create.
Anaesthetise condition.
So let us say we want to have a condition inside this flipflop.
And here we want to evaluate.
OK.
Food is yummy.
And.
Let us say we want to have another if condition inside this.
We can use El Sol Trujillo, but we are just using if.
So here, if you see, we have created this foundation, which has further information inside this envelope,
and it has some of the if condition, which has further information.
Now, if you see each condition has a further indentation associated with it, this is the last condition.
And this is the next if blog and prior to this, this was the original invasion, which we had.
So let us give the bad news.
Do it.
Let us see.
Geek is don't like.
And let the food.
The.
Now, let us run this piece of code so we can say no today, food is yummy.
Good.
So.
Cake is don't make so it says no cake today, then we have a food equal to tasty, then it is saying
that food is yummy and finally saying goodbye.
Apart from this, we can let us just change it a little bit.
And then it says, no gig today, and that is good bye.
We can also convert this into an air condition.
And this.
And for this, we will have to remove this emendations.
So now you can see that it has value, not the one place so close to this ayliffe block, it will run
this entire piece of code.
So the first statement is no cake today.
So it Prinstein then it evaluates this if condition.
Now it checks of full value is tasty.
So it is not d d d d d one.
So it moves to the S condition and runs it.
So, again, give me chocolate and good goodbye.
So that is if condition.
Thank you.