''' 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' if ( pH < ACIDIC_THRESHOLD ) : # python will evaluate this expression and enter the correct path according to the answer # if pH < ACIDIC_THRESHOLD evaluates to True, we enter this path because the flowers will be pink print( "pink" ) # soil is acidic -> produces pink mums else : # if pH < ACIDIC_THRESHOLD evaluates to False, we enter this path print( "blue" ) # soil is non-acidic -> produces blue mums # if statements: # if ( condition ) : # action_1 # else : #action_2 # the else is optional # action_1 and action_2 can contain if statements, loops, whatever you want # condition # comparisons are going to mostly be inside the parentheses at the definition of the if statement # condition will evaluate to a boolean true or false # we will extend the if statement longer using the elif ( else if (condition_2) ) keyword later # all done # discussion on 0 # some programming languages have positive and negative representations of 0, and you can learn more about # why that is in CS 2150/ whatever they're replacing it with