functions and functional programming in additionthe use of mutable objects as default values may lead to unintended behaviordef foo(xitems=[])items append(xreturn items foo( returns [ foo( returns [ foo( returns [ notice how the default argument retains modifications made from previous invocations to prevent thisit is better to use none and add check as followsdef foo(xitems=none)if items is noneitems [items append(xreturn items function can accept variable number of parameters if an asterisk (*is added to the last parameter namedef fprintf(filefmt*args)file write(fmt argsuse fprintf args gets ( ,"hello world" fprintf(out,"% % % " "hello world" in this caseall the remaining arguments are placed into the args variable as tuple to pass tuple args to function as if they were parametersthe *args syntax can be used in function call as followsdef printf(fmt*args)call another function and pass along args fprintf(sys stdoutfmt*argsfunction arguments can also be supplied by explicitly naming each parameter and specifying value these are known as keyword arguments here is an exampledef foo( , , , )statements keyword argument invocation foo( = = ='hello' =[ , ]with keyword argumentsthe order of the parameters doesn' matter howeverunless there are default valuesyou must explicitly name all of the required function parameters if you omit any of the required parameters or if the name of keyword doesn' match any of the parameter names in the function definitiona typeerror exception is raised alsosince any python function can be called using the keyword calling styleit is generally good idea to define functions with descriptive argument names positional arguments and keyword arguments can appear in the same function callprovided that all the positional arguments appear firstvalues are provided for all nonoptional argumentsand no argument value is defined more than once here' an examplefoo('hello' =[ , ] = foo( ='hello' =[ , ]typeerror multiple values for lib fl ff