The If condition is used when we want to execute statements only given condition is satisfied. It is declared by using the if
keyword followed by a condition which will evaluate to a boolean of either True
or False
.
For example in the below program if the signal is green
it prints Go ahead.
Change the signal
to the value "red" and see the result.