functions and functional programming ubstantial programs are broken up into functions for better modularity and ease of maintenance python makes it easy to define functions but also incorporates surprising number of features from functional programming languages this describes functionsscoping rulesclosuresdecoratorsgeneratorscoroutinesand other functional programming features in additionlist comprehensions and generator expressions are described--both of which are powerful tools for declarative-style programming and data processing functions functions are defined with the def statementdef add( , )return the body of function is simply sequence of statements that execute when the function is called you invoke function by writing the function name followed by tuple of function argumentssuch as add( , the order and number of arguments must match those given in the function definition if mismatch existsa typeerror exception is raised you can attach default arguments to function parameters by assigning values in the function definition for exampledef split(line,delimiter=',')statements when function defines parameter with default valuethat parameter and all the parameters that follow are optional if values are not assigned to all the optional parameters in the function definitiona syntaxerror exception is raised default parameter values are always set to the objects that were supplied as values when the function was defined here' an examplea def foo( = )return foo(reassign 'areturns (default value not changedf lib fl ff