If-Else statements are conditional statements used to perform decision-making in a program. They allow different blocks of code to execute based on whether a condition is True or False.
if Statement
The if statement is used to execute a block of code only when a given condition is True. If the condition is False, the code inside the if block is skipped.

i = 10
if i > 15:
print("10 is less than 15")
print("I am Not in if")
Output
I am Not in if
if-Else Statement
The if-else statement is used to execute one block of code when a condition is True and another block when the condition is False. It helps programs make decisions based on different conditions.

i = 20
if i > 0:
print("i is positive")
else:
print("i is 0 or Negative")
Output
i is positive
If-Else in One line
If we need to execute a single statement inside the if or else block then one-line shorthand can be used.
a = -2
res = "Positive" if a >= 0 else "Negative"
print(res)
Output
Negative
Logical Operators with If-Else
We can combine multiple conditions using logical operators such as and, or, not.
age = 25
exp = 10
if age > 23 and exp > 8:
print("Eligible.")
else:
print("Not eligible.")
Output
Eligible.
Nested If-Else Statement
A nested if-else statement is an if-else structure placed inside another if or else block. It is used to check multiple conditions step by step and execute code based on those conditions.

i = 10
if i == 10:
if i < 15:
print("i is smaller than 15")
if i < 12:
print("i is smaller than 12 too")
else:
print("i is greater than 15")
else:
print("i is not equal to 10")
Output
i is smaller than 15 i is smaller than 12 too
if-elif-else Statement
The if-elif-else statement is used to check multiple conditions one by one. When a condition becomes True, its corresponding block of code is executed. If none of the conditions are True, the else block runs.
i = 25
if i == 10:
print("i is 10")
elif i == 15:
print("i is 15")
elif i == 20:
print("i is 20")
else:
print("i is not present")