functions and functional programming programming style that is best avoided because such functions can become source of subtle programming errors as programs grow in size and complexity (for exampleit' not obvious from reading function call if function has side effectssuch functions interact poorly with programs involving threads and concurrency because side effects typically need to be protected by locks the return statement returns value from function if no value is specified or you omit the return statementthe none object is returned to return multiple valuesplace them in tupledef factor( ) while ( <( ))if (( dd = )return (( )dd return ( multiple return values returned in tuple can be assigned to individual variablesxy factor( return values placed in and or (xyfactor( alternate version same behavior scoping rules each time function executesa new local namespace is created this namespace represents local environment that contains the names of the function parametersas well as the names of variables that are assigned inside the function body when resolving namesthe interpreter first searches the local namespace if no match existsit searches the global namespace the global namespace for function is always the module in which the function was defined if the interpreter finds no match in the global namespaceit makes final check in the built-in namespace if this failsa nameerror exception is raised one peculiarity of namespaces is the manipulation of global variables within function for exampleconsider the following codea def foo() foo( is still when this code executesa returns its value of despite the appearance that we might be modifying the variable inside the function foo when variables are assigned inside functionthey're always bound to the function' local namespaceas resultthe variable in the function body refers to an entirely new object containing the value not the outer variable to alter this behavioruse the global statement global simply declares names as belonging to the global namespaceand it' necessary only when global variables will be modified it can be placed anywhere in function body and used repeatedly here' an examplef lib fl ff