result twice here is an example that uses itline 'bing tiddle line 'tiddle bang cat_twice(line line bing tiddle tiddle bang bing tiddle tiddle bang when cat_twice terminatesthe variable cat is destroyed if we try to print itwe get an exceptionprint cat nameerrorname 'catis not defined parameters are also local for exampleoutside print_twicethere is no such thing as bruce stack diagramsto keep track of which variables can be used whereit is sometimes useful to draw stack diagram like state diagramsstack diagrams show the value of each variablebut they also show the function each variable belongs to each function is represented by frame frame is box with the name of function beside it and the parameters and variables of the function inside it the stack diagram for the previous example is shown in figure fig stack diagram the frames are arranged in stack that indicates which function called whichand so on in this exampleprint_twice was called by cat_twiceand cat_twice was called by __main__which is special name for the topmost frame when you create variable outside of any functionit belongs to __main__