The if statement perform operation either condition is true or false.
If Statement
This statement execute the code if condition is true
if(condition) Statements Condition True
x = 5 if x==5: print "Hello World"
output:- Hello World
If-else statement
if-else statement execute the code if condition is true or false.
if(condition):False statements else:True statements
a = 10 if a%2==0: print "No Is Even" else: print "No Is Odd"
output:- No Is Even
elif statement
elif statement is used to execute one code multiple conditions
if expression: statement elif expression: statement elif expression: statement else: statement
a = 20 if a==10: print "Hello" elif a==20: print "Welcome" elif a==30: print "How Are You" else: print "No Value"
output:-Welcome