Syntax: if
if condition: # Code to execute if the condition is True
Syntax: if..else
if condition: # Code to execute if the condition is True else: # Code to execute if none of the above conditions are True
Syntax: if..elif..else
Performs a bitwise XOR operation between two integers. Each bit in the result is set to 1 if the corresponding bits of the operands are different, otherwise it is set to 0.
if condition: # Code to execute if the condition is True elif another_condition: # Code to execute if the second condition is True else: # Code to execute if none of the above conditions are True
Python program that demonstrates the use of if..elif..else:
# Define a variable number = 15 # Conditional statements if number > 20: print("The number is greater than 20.") elif number == 20: print("The number is exactly 20.") else: print("The number is less than 20.")