Hello to all of my students, and now we're just going to see some examples regarding your state's statements,
the basic part, and I was always a fan of starting easy and then like increasing the speed.
So to understand all the basics, you always have to start from basics, right?
You can just go from zero to 60 in one second.
And I'm always a believer of getting the things breaking down into small pieces and go further in steps.
All right.
So once you open your project, just create a new file.
You can call it if statements basics.
And right now, I'm just going to show you some examples from the previous lecture so it could sink
in your in your mind.
And I think we'll get the hang of if statements more easily after seeing these examples.
All right.
So first of all, let's just create here a comment for us in the future, as always.
And let's head off with a simple example.
So, first of all, let's create a salary variable integer that set is as a thousand and let's return
each statement.
So I just want to say that if salary is bigger, right, because this mathematical sign points towards
salary, this means salaries bigger, then five thousand, then two that I want to print.
My salary is too low.
I need to change my job, so sort of a joke.
All right.
And then right here else, as you recall from the previous lecture, like if this is the output of that
statement is true.
So this would be executed.
Everything under the earth would be executed.
But if it's not true, meaning it's false, the house is the default exit point, meaning that if this
won't be ran, so everything under else would run.
All right.
And right here, I want to say salary is above 5000.
It's OK for now.
Right.
So and this statement we can see here a true value because our salary is eight thousand.
And the statement says the salary is above five thousand and this is actually above above five thousand.
So this we expect this one to print.
Let's run it and make sure that this happens.
Great.
So as you can see.
Yeah, the statement, the print under the if condition was printed out.
And let's just try to play with it a little bit.
Let's just set here four thousand nine hundred ninety nine and let's run it now.
All right.
As you can see accordingly, as we change the value of the salary, which is now smaller or smaller
than five thousand.
Now, it's it did not print this print out, went to alse, which is the point.
And after that, the cold exits the if completely meaning whether this printout out or this this out
after one of them is executed, the code goes down to here and sorry.
Here.
Yeah.
Just want to show you, like going here, yeah, and going down here, exit the if statements completely.
All right, so it runs only one time.
But let's see what happens if we put 5000.
Exactly.
So 5000 is 5000, bigger than 5000.
Anyone knows.
So the answer is.
Yep, the answer is this one false.
All right, so why because 5000 is not bigger than 5000, it equals the five thousand.
But if we put an equals mark right here like this, this means we can do we can put two operators here,
pool math, two math operators here.
We're saying here, if it's equal, if it's bigger, if salaries bigger or equals 5000, then execute
this line right here.
So let's run it.
Whoa.
Yet.
So we can see that this one was printed out because we added the equals mark right here, meaning it's
bigger or equals than 5000.
So this statement is true.
But once we removed this one.
So this statement is false.
And once it's false, this will not run.
The default exit point will be executed, which is the yellow.
So as you just saw, I did some experiments here.
And programming is all about experience.
My friends, you always need to experiment.
And once you see, like a statement that you're not really familiar with and you don't really know what
it does, just try to play with it.
Just try to change the values right here and see what will happen that way.
According to the output, you can learn about the body of the statement that we're learning.
All right.
So just changing the values here made me learn a lot about the statement.
Let's go over to the next statement.
I'm just going to put age 30 here.
And if age is bigger than 50, then I want to present you are above 50.
You are a senior developer for sure.
Yep.
Just a joke.
Right?
Then we can put an L if here.
And if you recall from the previous video, we used one example for if else only and one example for
if ayliffe example, once we have several options, several conditions.
So if age bigger than 40 and right now we want to present you, your age is bigger than 40, you are
a developer for some time.
But if not.
It's better late than never.
All right.
I really believe in this sentence because I always believed in challenging yourself, not doesn't matter
what age you are, and it's never too late.
All right.
So this one was the second statement.
And let's add another one, a much bigger than thirty five.
So you are more than thirty five years old, I might guess you are a developer.
I'm I'm running out of ideas, actually.
All right.
So this one is another else.
If you remember, that leaf is a short for ayliffe.
All right.
And here in the house, just want to print.
Doesn't matter.
Doesn't matter what age you are.
Let's called Biton.
Yeah.
So right now we have all these statements written down here and our age is 30 or so.
Is this statement true?
It's about 50.
Age is bigger than 50.
No age is 30.
So this statement is false.
It would not be executed.
Is age bigger than 40?
No, it's false.
So this one would not be executed as well.
Is bigger than the thirty five false as well.
So what are we going to be a game come up with is this default mode, which is the LTH because all of
these are false for now and this one is the default exit point.
If none of these will be true, the owls would be executed as the default exit point.
So let's try to run it.
All right.
So you see it right now that in matter of fact, like the else was printed and this was the exit point.
All right.
Again, let's try to just do some manipulations here.
Let's just put the age three hundred, all right, like we're a mommy or something.
And once we run it, let's see what happens.
All right.
This this sentence like this if statement was first in line.
So this was the first one to be checked and it came up true.
So this print was executed and once one of them.
All right.
I'm focusing on the sentence once one of them was executed or in other words, once one of these alif
or if one of these conditions was true, the code exits the whole bulk of if completely and continues
down here.
All right.
That's just verified, right?
You see, so once this statement was true and the print this print was executed, they called after
finishing with all of this part because one of them was true, went over to this point right here.
And it ignores all the other else if and Elsas and if so, only one of them can be executed.
And the first one that would be true would be the one to be executed, even though even though that
this statement is also true.
Right.
Because the age is 300 and it's bigger than 40.
Doesn't matter.
It doesn't matter.
The Python Python programming the if statement in Python programming works that way that only the first
true statement would be executed and all the rest would be ignored.
All right.
So that's about it for the advanced part, the basics one part.
And these examples are too huge to be deployed after we learned that during the previous lecture.
So this gives you the feeling what if statements are all about and you see some examples you really
recommend to take this code.
You have it attached to your lecture and to paste it in your pie chart and start to play.
Playing with it like adding equals here and changing the numbers as well as we did right here just to
get the hang of it much better.
And I'll see you in the next video where we can see some more advanced examples.
Thank you and bye bye.