''' Purpose: demonstrate optional parameters ''' def test_chant() : ''' Perform simple testing of alma.chant() ''' import alma print( 'chanting with no parameters' ) print() # if we do not provide any of the two parameters for chant() # it uses the default values: # msg = "Wahoo Wa" # n = 3 # we chant "Wahoo Wa" 3 times alma.chant() print() print( 'chanting with message parameter set' ) print() # because we are only passing in value for 1 parameter for chant() # we must say: parameter_name = "the value" # we didn't pass in the second parameter n, so it defaults to 3 # --> print "Hip hip hooray!" 3 times alma.chant( msg='Hip hip hooray!' ) print() print( 'chanting with number of repetitions set' ) print() # here, we did not pass in a value for msg parameter --> default parameter of "Wahoo Wa" # we pass in a 5 for the n parameter # we chant "Wahoo Wa" 5 times alma.chant( n=5 ) # if we don't put n= in front of 5, the parameter will be automatically assigned to the first parameter # which is msg = 5 # so we print 5 three times because n defaulted to 3 alma.chant(5) print() print( 'chanting with arguments for message and repetition parameters' ) print() # here we pass in values for both parameters # since nothing is optional here, each value will be assigned to each parameter in order # msg = 'We are CS 1112' # n = 1 # we chant 'We are CS 1112' once alma.chant( 'We are CS 1112', 1 ) # run tester test_chant()