Friday, 13 September 2013

How to implement If condition in python

                                                  If Statement




If condition is used to decision making ,so if statement is also know selection statement


Syntax:


if  condition :
  Statement ;
else:
  Statement;




Programme:


a=20
print('enter any numb')
x=int(input())
if x
    print('oops guess larger number')
elif x>a:
    print('oops guess smaller number dude')
else :
    print('wow exact guess it is :)')




Output:



>>> ================================ RESTART ================================

>>> 

enter any numb

5
oops guess larger number
>>> ================================ RESTART ================================
>>> 
enter any numb
20
wow exact guess it is :)
>>> ================================ RESTART ================================
>>> 
enter any numb
25
oops guess smaller number dude
>>> 

No comments:

Post a Comment