If is a keyword used to condition the output. For example you want the greater of two variables.
If a>b :
Print a
Else :
Print b
Note that the colons are important part of the syntax also look out for the indentation of the print commands. The ELSE statement is not needed to be conditioned as it takes all the other remaining types of outputs. The ELSE statement can also preceded by a ELIF statement. The ELIF statement can also be conditioned the same way as the IF statement followed by the colons.
These were the common IF statements, you can further condition your if statements by using the AND & OR commands.
The output for the conditions for AND statements are
True AND True = True
True AND False = False
False AND False = False
True AND False = False
The output conditions for the OR statements are
True OR True = True
True OR False = True
False OR False = False
True OR False = True
The IF conditions with the AND or OR statements are called as COMPOUND IF CONDITIONS.
Example-
If a>b and a>c:
Print a
When there is an IF condition within an IF condition, they are known as the NESTED IF CONDITIONS
Example-
If a>b:
If a>c:
Print a
The conditioning statements AND & OR are known as the logical operators and results in the answer being true or false. Another condition comes under the logical operators, the NOT statement. Otis used to negate a condition.
If a>b :
Print a
Else :
Print b
Note that the colons are important part of the syntax also look out for the indentation of the print commands. The ELSE statement is not needed to be conditioned as it takes all the other remaining types of outputs. The ELSE statement can also preceded by a ELIF statement. The ELIF statement can also be conditioned the same way as the IF statement followed by the colons.
These were the common IF statements, you can further condition your if statements by using the AND & OR commands.
The output for the conditions for AND statements are
True AND True = True
True AND False = False
False AND False = False
True AND False = False
The output conditions for the OR statements are
True OR True = True
True OR False = True
False OR False = False
True OR False = True
The IF conditions with the AND or OR statements are called as COMPOUND IF CONDITIONS.
Example-
If a>b and a>c:
Print a
When there is an IF condition within an IF condition, they are known as the NESTED IF CONDITIONS
Example-
If a>b:
If a>c:
Print a
The conditioning statements AND & OR are known as the logical operators and results in the answer being true or false. Another condition comes under the logical operators, the NOT statement. Otis used to negate a condition.