''' Purpose: introduce decision making ''' # determine chrysanthemum color given an input soil pH level # acidic soil produces pink chrysanthemums # non-acidic soil produces blue chrysanthemums # acidity threshold ACIDIC_THRESHOLD = 7.0 # samples less than threshold are acidic # get soil pH level of interst reply = input( 'Enter soil pH level: ' ) pH = float( reply ) print( ) # analyze and report effect on chrysanthemums # if acidic print 'pink'; otherwise print 'blue' # Let's make our lives easier and define the constants for lowest and highest pH levels. LOWEST_PH_LEVEL = 0.0 # HIGHEST_PH_LEVEL = 14.0 # We cannot accept pH levels lower than 0.0 and higher than 14.0 # If it's less than 7.0 we know that our flowers will be pink. # If it's greater (any other case) we know our flowers will be blue. if ( pH < LOWEST_PH_LEVEL) : # print( "Illegal pH level: ", pH ) elif ( pH > HIGHEST_PH_LEVEL ) : print("Illegal pH level: ", pH) elif ( pH < ACIDIC_THRESHOLD ) : print ( "Pink" ) #is acidic else : print( "Blue" ) # It's useful to leave the biggest condition in the else statement. # all done