Python Decision-Making

Decision making is nothing but to evaluate 2 or more conditions and according to result give the output.


Syntax

if condition:
   statement 1
   statement 2
else:
   statement 3

Example

  1. if 2<3:
  2. print "it is not good"
  3. else:
  4. print "it is too good"


Output

 it is not good
 


  1. a = 20
  2.  
  3. if ( a == 20 ) : print "Value of expression is 20"
  4. else: print "Good bye!"

In the next chapter you are going to learn loops in python