four type of Branching statement:
# 1. Simple if statement.
# 2. if.......else statement.
# 3. elseif ladder statement.
# 4. Nested if statement.
1.SIMPLE IF STATEMENT:
1) In this evaluate process the condition must true then only it will do next process.
2)If the condition is false there is nothing to happen automatically came out the process.
2.IF......ELSE STATEMENT:
1) If the condition is true it will do only one work.
2) If the condition is false it will do another work.
3.ELSE IF LADDER STATEMENT:
3) It will be Executed in step by step process and this process will
be hope where the condition is true.
4. NESTED IF STATEMENT:
In this condition having one if statement itself having another if statement on that.
Example:
SIMPLE IF STATEMENT:
a=5
if a==5: # Evaluate the condition is TRUE.
print("welcome")
OUTPUT:
welcome
2.IF......ELSE STATEMENT:
a=5
if a==4:
print("welcome")
else:
print("hello") # Evaluate the condition is FALSE.
OUTPUT:
hello
3.ELSE IF LADDER STATEMENT:
a=int(input("enter the value"))
if a==4:
print("four")
elif a==5:
print("five")
elif a==6:
print( "six")
else:
print("hello")
OUTPUT:
enter the value: 5
five
enter the value: 4
four
enter the value: 7 #we assing except this values automatically go to else part
hello
and print hello
4. NESTED IF STATEMENT:
a=int(input("enter the value"))
b=int(input("enter the value"))
if a==4:
if a>4:
print('yes")
else:
print("no")
else:
print("terminate")
OUTPUT:
