''' Purpose: demonstrate optional parameters ''' # Optional Parameters are defined where we supply a default value for # the parameter if we don't provide an argument to the function. # So we can specify nothing and use default values for both arguments, # specify one of the parameters # and use the default value for the other, or we can supply values for both to not use the default # values. # def function_name( optional_parameter=default value) <- use default value if there's no # arguemnt provided # def function_name( parameter ) <- what we've been doing so far - argument is required # since there's no default. def chant( msg='Wahoo Wa', n=3 ) : ''' Prints string parameter msg, n times ''' for i in range( 0, n ) : print( msg ) # if (__name__ == '__main__' ) basically says "See if we're in the file # that we're running or if we're in an import") # If it is, then we run the code indented into the if statement. # If this file is the one being run, the Python variable __name__ (an internal # variable defined by Python creators) is set to '__main__' # Do not modify this part on homework / tests because this is what will # allow you to test your code. You're only responsible for writing the functions above! if ( __name__ == '__main__' ) : # This basically lets us run mater that tests alma by running alma module itself import mater mater.test_chant()