Welcome back.
Sometimes you want your program to do different things based on certain conditions.
Python uses if Elif which is else, if and else for decision making.
For example, we have this age equals to 15 age variable.
Let me test this age variable and make conditions according to this value.
If age greater than or equal to 18, go and print.
You are old enough to vote.
Otherwise, if age is less than 18, go and print.
Sorry, you are too young to vote.
Run the application age equals to 15.
Sorry your your are too young to vote.
Change it to 20.
Run the cell you are old enough to vote.
So here we are using the age to check its value.
If it is greater than 18, go and print this and if it is less than 18, go and print.
Sorry, you're too young to vote.
You can check multiple conditions using Elif.
For example, if our age equals to 20, here we have three.
Uh, three options.
If age is less than 13, print you are a child.
If it is less than 18.
Create a new message.
You're a teenager, and if it is greater than 18, print.
You are an adult.
Let me run and here we go.
You are an adult.
Change it to 15.
For example, run the cell and you are a teenager.
We are printing this state.
Change it to ten here.
If age is less than ten.
Yes, the program puts ten here.
The value of age which is ten.
Ten less than 13.
Yes.
True.
Go and execute this line of code which is printing.
You are a child.
So in this way the Python compiler executes the code.
Okay, you can even nest if statements inside others.
For example, we have age equals to 15 and we have another variable called has permission which is set
it to true.
Now if age equals to 18 or age less than 18.
Print.
You are a teenager now inside this if we need to create a nested if condition.
Another nested if condition here.
If we have a permission, go and you can watch PG 13 movies.
Else print you need parental permissions.
Let me test and see.
You are a teenager.
You can watch PG 13 movies.
Now let me make this to false run.
You are a teenager.
True, you need parental permissions.
Okay, so here we learned how to create a nested conditional statement inside the outer conditional
statement.
Okay you see guys how we use this conditional statements and the nested conditional statements.
And those are very crucial for our decision making and for our programs because we need to create a
lot of those conditional statements in our programs.