Python If Else Statements

In this page you learn an else statement can be combined with an if statement. An else statement contains the block of code that executes if the conditional expression in the if statement resolves to 0 or a FALSE value.

Syntax

if(expression):  False  
             statements  
    else:   True  
              statements 
	
if-else

Example of If Else statement

year=2000  
if year%4==0:  
    print  "year Leap"  
else:  
    print "year  not Leap"  
 

Output

Year is Leap