Hello to all the students, and in this video, we'll try to see the examples that we have been over
in the previous lecture.
All right.
So once the project is open, just create a new file.
As always, you can call it if statements basics, part two.
And right here we can write if statements.
BASIX far too surprisingly right.
And let's bring out the age equals 30 variable that we really love and and then put a name variable
equals to James.
Right.
And right here, let's see example number one, which will be logical operator.
And in this example, we'll try to compare the age.
We'll put age bigger than 20 and name double equals James.
Right.
So you can see both examples right here.
The double equals and also the logical operator does have the opportunity to use them both.
Here you can see that all of our material and all of our theory eventually comes together with strings,
logical operators, double equals sign and so on.
All right.
So right here, let's just print example one.
And we have my name is James and.
I'm.
Over 20.
All right, and also I can drink now in some countries, I'm just joking, it's not educational for
those of you who are under 18.
It's not educational.
All right.
So you can see right here, my name is James and I'm over 20.
And this one, we can see that once we to the logical operator right here, it's marked with orange.
Same as if it means that this is a saved word in Python.
It's saved for a special, special word.
And you can see why it's special because it's used in if statements you see Boolean Operator.
Well, it has many names, like it depends on which platform and where you read about it here.
Pyfrom saw slabs, not slabs, though, called Jedburgh.
The guys that who invented by charm, they call it Boolean Operator.
All right.
So you see it's a special word, same as if, for example.
All right.
By the way, if you want to read about if you can read about it once you hover above it, it's already
recommended because you can learn from everything.
Like, for example, you can read it and from here understand something you that you didn't know before.
All right.
And right here, we can put the alse.
And both your example one.
Default exit point.
I'm writing this because I don't really care what they print, I just want to show just want to see,
like, whether the code went to this bulk or to this bulk.
Right.
This is what interested me, the exit point.
So both of these values must be true because we have there and logical operator, I hear once one of
them will be false, that this thing would not be executed, but this thing would be executed.
So let's try to feel it, feel it and see what happens.
By the way, you can see here that we used a double equals Mark, and once I race one of them, we have
an error because once we hover above it, yeah, we're having some kind of error here.
Like the error error message doesn't even help us with anything.
Python doesn't know what to do with what to do with it.
That's it.
So once we do this double equals log, everything's solved.
All right.
So right now, let's try to change it to Gaim and see whether this one would be executed.
Let's try to run it.
And as you can see, it goes straight to the default exit point because one of these values is false.
All right.
So for this one as well, like age is 30.
And once we just change it, for example, we put Dan here.
So this one would be false right now.
Try to run it.
Also default exit point.
And once we turn it to 30, 30 is bigger than 20.
We run it right now and everything's fine.
Right.
So this executes once this value and this value, they're both through output's.
All right.
Let's go straight ahead to the next example.
And it's a similar to this one, actually.
We don't need the second example.
We can just use this.
No.
Yeah, we could just put here and change it to or.
All right, or maybe the best thing to do is just copy it so you have it in your attachment file of
code, both examples, right?
So just copies right here.
And then problem resolved, just change this one to two and this one to two as well, and he went in
and out of space and he we need or it's already and here we put.
All right.
We'll find out.
Right.
Just copy all the bulk of code and just, I believe in shortcuts.
All right.
I believe in shortcuts because there are some specifical like specifical work that you don't need to
rewrite it again because it's the same code we just change this value to or that seats don't need to
write it again.
Just market.
Right.
Click copy and paste it below.
All right.
So right here we have the same the same statements as we have in the first in the first example.
But right here we have the order.
And that means that once one of them is through one of these, that one or that one is true.
So the values would be the output would run this code.
All right.
So let's see, let's run it first time was both of them true?
So once both of them are true, you can see that the chunk below the difference because we need at least
one and once both of them are true.
So obviously this one will draw on.
But also if I put a 10 here.
All right, I don't care what happens in it, for example, for now, I specifically changed this value
to see what happens in example number two.
So ignore what you see, the output of you right now.
All right.
So just run it.
All right.
Still, you can see in the second example, my name is James and I'm over 20.
So this line runs.
All right, this one, this line runs, even though the output of this age, bigger than 20 is false.
Once we have age equals then and only this one is true.
So we can see that or logical operator works properly.
And it helps us to determine even if one of them is one of them is true.
So we will have a positive output right here under the IF.
But what happens once both of them are false.
All right.
Both of them false.
You can see an example, number two, that obviously goes to the default exit point, which is the false.
All right, so that's about it, regarding the logical operators, they're pretty easy.
All right.
As you can see, pretty easy.
Nothing special here and same as simple if statements.
But now we have two statements in the same if and just we have a connector, which is the logical operator
between them.
All right.
The third example will be dedicated, obviously, to the nested if because it's really important to
understand.
It's also how it will also help you further down the road with the final project.
We're going to create at the end.
All right.
So right here, I'm just going to add another variable called Married.
True, like that, and then I'm going to do like this, if age bigger than 20.
And name equals.
James.
Just copying the top the top line right here and then, all right, so just want just a quick reminder,
the nested if statements says that under the first main, if we going to insert the nested part.
So right here, we're going to have another if and just going to put here married.
Double equals true, which is a boolean variable, right, if married equals true, then I'm going to
say to the guy, first of all, example three, good luck.
It's gonna be a long, happy road, right?
Being optimistic.
Yeah, it's not cynical.
I'm really not.
All right.
Yeah.
It's going to be a long happy.
Right.
All right.
So if you're bigger if you're older than twenty and your name is James and you're married.
All right.
You're hearing me, James, if there is a student named James is for you.
Right.
So if this would be true, both of these values would be true.
And then if only if both of them are true, we're going to go inside here.
But.
We're going to do it here, the nested.
Nested alse.
Yeah, and you need to dots here and also we need to have the parent else as well.
Uh prent.
Example three.
An apparent.
Parent alse, yeah.
All right, so that's about it, so you can see the following flow.
We're going from top to bottom.
We're coming this line right here.
And the question is age above 20 through then we have and yeah, then we have the end name equals James
also Drew.
And just because of because both of them are true, we're going to this chunk right here.
We're not caring about this L'Esperance here.
We're just interested in the chunk below the left and right here.
We also have additional if this one is in nested if and we ask again, is married equals true.
And if it's true, we run this code if it's false on this code.
All right.
Let's try to fail it, fail it in advance and and try to get this line right here.
So basically, what we need, we need to fail one of these terms right here and then fail the if statement
right here.
So, first of all, going to put false not married.
So this one would be false.
This will help us to get here.
And also, I'm going to change the age to 10 going around the code now.
And the only thing that interests me is example number three.
All right, great.
Not really great because I made a mistake.
And it's a good mistake because we can learn from it once.
This one is false.
So all of the code got to go down here.
And why?
Because we need both of them to be true in order to get to this part that I marked right here, and
once this one is false, we're going straight ahead to the parent house.
So let's get it back to be 30 and run it right now.
And we'll get to this line right here, Ron.
Hoo.
Yeah.
So.
This false.
This one is sorry, this one is true, this one is true.
Now we got to this chunk right here and we're asking if married is true.
And the answer to this part is false because it is not true.
It's false.
So this one is a false statement, right?
Remember this sentence?
It's a false statement.
It's not.
It's like it's a lie.
In other words, this one is a lie.
This one is a lie because married equals true.
It's a lie now.
Married equals false.
So it's a lie.
So because it's a lie, we're going here to the house.
Very, very simple.
All right.
I think this covers the advance sorry.
The bases, part two.
And we have seen lots of examples in the previous lecture and we have seen them in live right by charm.
I think we're ready to go ahead and start the advance part of if statements over there.
We'll see much more examples will expand our knowledge.
And right after we will have a wide assignment for these statements because it's really important to
understand it.
And also, don't hesitate to try to resolve your assignments by yourselves after the advanced lectures.
And that's about it.
I will see you in the next video.
Thank you.