if else statement

Executes if block when condition is true, otherwise else block will be executed.

int_var = int(input("Please enter an integer: "));
if int_var % 2 == 0:
print("even"); # prints even when number is even and not zero
else:
print('odd'); # prints odd when number is not 0 and not even

elif statement

Used to provide the additional conditions along with if.

int_var = int(input("Please enter an integer: "));
if int_var == 0:
print("zero") # prints zero when number is 0
elif int_var % 2 == 0:
print("even"); # prints even when number is even and not zero
else:
print('odd'); # prints odd when number is not 0 and not even

Nested if statements

if block can have another if block or if else block. else and elif blocks also can have same.

int_var = int(input("Please enter an integer: "))
if int_var % 2 == 0:
if int_var == 0:
print("zero");
else:
print("even"); # prints even when number is even and not zero
else:
print('odd') # prints odd when number is not 0 and not even