Python - Decision making (if-else)




  """
      created_at       : 08 Feb 2017.
      updated_at       : 08 Feb 2017.
      aim of script    : To understand the concept of if-else (decision making) in python.
      coded by         : Rishikesh Agrawani.
      Python version   : 2.7.12
  """

  a = 10                          #a is initialized to 10
  b = 5                           #b is initialized to 5
  c = 2                           #c is initialized to 2
  d = (10/2)                      #d is initialized to 5

  print a,b,c,d                   #10 5 2 5

  if a == 10:                     #Condition is true
      print "a is equal to 10"    #It will get executed    
  else:
      print "a is not equal to 10"


  if b != 5:                         #Now condition is False
      print "b is not equal to 5"
  else:
      print "b is equal to 5"        #It will get executed


  if (d==5) and (c==2):                             #True
      print "d is equal to 5 and c equals 2"        #It'll execute
  else:
      print "d is not equal to 5 and c is not equal to 2"


  if 3 < 10:                         #True
      print "3 is less than 10"      #It will get executed
  else:
      print "3 is not less than 10"


  if 3 > 10:                             #False
      print "3 is greater than 10";      #; can be excluded at the end of the statement
  else:
    print "3 is not greater than 10";    #It will get executed


  if ((55/11) + (45-40)) <= 10:            #5 <= 5
      print "(55/11) + (45-40) is less than or equal to 10";       #It will get executed
  else:
      print "(55/11) + (45-40) is greater than 10";


  if (19**2) >= (100*4):                   #361 >= 400
      print "(19**2) is greater  than or equal to (100*4)"       
  else:
      print "(19**2) is not greater than or equal to (100*4)"      #It will get executed