''' 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 statements # allows you to test a logical expression and if the expression evaluates to True # we do the things indented into the if statement # if (test): # do this # else: (the if statement wasn't true so we do this) # do this # if acidic print 'pink'; otherwise print 'blue' if ( pH < ACIDIC_THRESHOLD ): # If the test inside the parentheses evaluates to True we jump into the indented block color = 'pink' else: # pH was not < ACIDIC_THRESHOLD (the if test wasn't True so we jump into this block) color = 'blue' print( 'Soil sample makes chrysanthemums', color ) # all done # test expression is something that uses a logical/relational operator that will evaluate # to True / False # if (test expression): # Indented statements are executed if test expression evaluates to True # else: # test expression wasn't true so we jump into this indented block