''' Purpose: demonstrate optional parameters ''' def chant( msg="Wahoo Wa", times=3 ) : for i in range( 0, times ) : print( msg ) if ( __name__ == '__main__' ) : chant() # Optional parameters allows you to use the default values the # user provided in the function definition for the parameter # It says "Hey! If you don't give me an argument, I'm just going to # use this default value." # ^ as seen above parameter = default value print() chant( msg='Hip hip hooray!' ) # Passing in argument 'Hip hip hooray' # for the parameter msg but default value for # times is still 3! print() chant( times=5 ) # Pass in 5 as argument for parameter times but msg is still # the default value of "Wahoo wa" print() chant( 'We are CS 1112', 1 ) # Now we pass in two arguments! The parameters # get the argument values in the same order # (normal function calling) so # msg gets 'We are CS 1112' and times gets 1 # Optional parameters allow you to either pass in the argument you want # or a default value passed in as the arguments for those parameters!