Conditional statements in Python allow us to control the flow of execution based on conditions. In this post, we’ll explore different ways to use if, if-else, logical operators, and inline decision-making.
Basic if Condition
The if statement executes a block of code only if the given condition is True.
if True:
    print("Statement is true")  # Output: Statement is true
if False:
    print("Statement is false")  # No outputExample: Checking a Number
x = 20
if x > 10:
    print("X is greater than 10")  # Output: X is greater than 10
x = 20
if x < 10:
    print("X is less than 10")  # No output