statement or expression examples global 'olddef changer()global xx 'newnonlocal ( xdef outer() 'olddef changer()nonlocal xx 'newyield def squares( )for in range( )yield * lambda funcs [lambda xx** lambda xx** why use functionsbefore we get into the detailslet' establish clear picture of what functions are all about functions are nearly universal program-structuring device you may have come across them before in other languageswhere they may have been called subroutines or procedures as brief introductionfunctions serve two primary development rolesmaximizing code reuse and minimizing redundancy as in most programming languagespython functions are the simplest way to package logic you may wish to use in more than one place and more than one time up until nowall the code we've been writing has run immediately functions allow us to group and generalize code to be used arbitrarily many times later because they allow us to code an operation in single place and use it in many placespython functions are the most basic factoring tool in the languagethey allow us to reduce code redundancy in our programsand thereby reduce maintenance effort procedural decomposition functions also provide tool for splitting systems into pieces that have well-defined roles for instanceto make pizza from scratchyou would start by mixing the doughrolling it outadding toppingsbaking itand so on if you were programming pizza-making robotfunctions would help you divide the overall "make pizzatask into chunks--one function for each subtask in the process it' easier to implement the smaller tasks in isolation than it is to implement the entire process at once in generalfunctions are about procedure--how to do somethingrather than what you're doing it to we'll see why this distinction matters in part viwhen we start making new objects with classes in this part of the bookwe'll explore the tools used to code functions in pythonfunction basicsscope rulesand argument passingalong with few related concepts such as generators and functional tools because its importance begins to become more apparent at this level of codingwe'll also revisit the notion of polymorphismwhich was function basics