The World of Conditional Statements

Conditional Statements are statements that set a condition for the code. An example is: if i==True:. That is a statement that sets a condition. So if i==True is True, then it would run the code in the if body. If the statement is false, it would just skip the if body and move on with the code. Before we get too much into if statements, let's look at the basics.

I play golf every day. But, when it’s raining I won’t play golf. So, we can set a condition.

As you can see, we can use conditional statements in our everyday life.
The if statement is not the only statement that can set a condition. The elif and else also can set conditions. Let’s talk about elif statements. If the if statement is false, you can add an elif statement to set another condition for your code. You can add multiple elif statements.

Now let’s talk about the else statement. If all the statements you add are false, you can use the else statement. The else statement doesn’t specify a condition. It just says ‘Hey, if all you guys are false I will execute my else body.’

That is all about conditional statements.