''' Purpose: demonstrate optional parameters ''' # So now we are considering optional parameters, where # for given parameters defined in the function definition, # we don't have to supply those if we say that they have # default values filled in for them. # In a normal function # chang( def chant( msg="Wahoo Wa", times=3 ) : for i in range( 0, times ) : print( msg ) if ( __name__ == '__main__' ) : # Modules typically contain solely function definitions. # However, now we're saying if we're in the module that # contains those functions, we can also just run the test # within the same module by identifying that # the __name__ for this Python program is '__main__' # meaning we can just run the program (testers) using # functions directly from this module since this module # is __main__. # Since we're in the module, __name__ is __main__ # If we weren't, it would be like cheer (module name) chant() # Notice how we didn't supply msg and times print() chant( msg='UVA NCAA Basketball champs' ) # Now we said message # is going to be something else but the default value for # value of times is default 3 (we didn't need to fill it in) print() chant( times=5 ) # Our default message is still Wahoo Wa # but our times is 5 print() chant( 'We are CS 1112', 1 ) # now we filled in both message and # times so those are the arguments we provide for those # parameters now # Optional parameters have to be the last ones in the definition # Sooo don't do def f(x = 2, y) do like f(x, y=2)