Python Conditional is like a fork in the road.
If something is
True, do this, if something is
False, do that.
The main start of the python conditional world is the
Python if statements will look at a statement, evaluate if it is
False, and then run different code depending on the outcome.
if True: # Do Something If True else: # Do Something If False
This if statement is known as a conditional.
Let’s take a look at a python conditional code sample
Think of conditionals as forks in the road. If something is True, then you go one way, if something is False, then you go another way.
This helps your program run certain pieces of code at some points, and other pieces of code at other points.
Let's look at a standard if...else statement. This is known as a conditional statement.
x = "Sunny Day" if x == "Sunny Day": print ("Mow The Lawn") else: print ("Wait Till Sunny Day")
Mow The Lawn
y = "Rainy Day" if y == "Sunny Day": print ("Mow The Lawn") else: print ("Wait Till Sunny Day")
Wait Till Sunny Day
Check out more Python Vocabulary on our Glossary Page