programplug Logo




Python If,else,elif Statement


The if statement perform operation either condition is true or false.


  • If statement
  • If-else statement
  • elif statement
  • Nested if

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







Our Services

Developing Cheapest Websites
Offer Digital Marketing
Provide College Projects
Attractive Website Developing
Summer Training,Industrial Training
SCO,SMO

Contact Us

Dehradun Uttarakhand India
www.programplug.com
info@programplug.com
08534019974
Designed By : Mridul Gupta

Other Link

About Us

Contact Us

Disclaimer

Privacy Policy