Conditionals

Conditional Statements are very important and very useful, and are used in almost every code. To quickly and easily understand what Conditional Statements are, consider this scenario:

if it is raining outside:
 bring the umbrella
else:
 do not bring the umbrella.

Now, if you want to bring this into Python, it would look something like this:

if condition:
 process
else:
 process

But what if there are more than 2 conditions? There is a solution for that too.

If we have more than 2 conditions, we use elif. This is short for else if.

Let's write a program to see if a number is greater than 15, less than 15, or equal to 15.

Because our number is greater than 13, the output of this program would be: lesser

Now, we could also write the same code in a different way.

This code goes through the same process the previous code does, except in this code, we have a condition inside of a condition, which is called a nested condition.