In this article let us look at the logical condition statements in Python. The condition statements usually come together with the if else statement.
Find whether a number is equal to or greater than one or else return false.
a = 3 if a == 1: return True elif a > 1 : return True elif a < 1 : return False
The above will return True. Notice that the elif statements simply stand for else if in Python.
Find whether a is equal to b or not.
a = 3 b = 3 if a != b: # if a is not equal to b return False else: return True
The above will return True as well.
The if else statement in Python is like the if else statement in other programming languages thus if you know how to write the if else statement in Java or C++ then it is really simple to apply the same rule in Python.