Python tutorial part 17 :- python if else statements

Python If Else Statements


 

The If statement is used to test specified condition and if the condition is true, if block executes, otherwise else block executes.The else statement executes when the if statement is false.

 

Python If Else Syntax

 

if(condition):  False  

             statements  

    else:   True  

              statements  

 



 

Example-

 

year=2000  


if year%4==0:  

    print  "Year is Leap"  

else:  

    print "Year is not Leap"  

Output:

Year is Leap

 

1 comment:

Quick Tech