text(point(- ) 'draw(wintext(point(- ) 'draw(wintext(point(- ) 'draw(wintext(point(- )' 'draw(windrawbar(win principalfor year in range( )principal principal ( aprdrawbar(winyearprincipalinput("press to quit "win close(main(you can see how drawbar has eliminated the duplicated code should we wish to change the appearance of the bars in the graphwe only need to change the code in one spotthe definition of drawbar don' worry yet if you don' understand every detail of this example you still have some things to learn about functions functions and parametersthe exciting details you may be wondering about the choice of parameters for the drawbar function obviouslythe year for which bar is being drawn and the height of the bar are the changeable parts in the drawing of bar but why is window also parameter to this functionafter allwe will be drawing all of the bars in the same windowit doesn' seem to change the reason for making window parameter has to do with the scope of variables in function definitions scope refers to the places in program where given variable may be referenced remember each function is its own little subprogram the variables used inside of one function are local to that functioneven if they happen to have the same name as variables that appear inside of another function the only way for function to see variable from another function is for that variable to be passed as parameter since the graphwin (assigned to the variable winis created inside of mainit is not directly accessible in drawbar howeverthe window parameter in drawbar gets assigned the value of win from main when drawbar is called to see how this happenswe need to take more detailed look at the function invocation process function definition looks like this def () technicallyit is possible to reference variable from function that is nested inside another functionbut function nesting is beyond the scope of this discussion