noteon fast enough computer you can make many consecutive changes to an image before the next sleep statementand they all appear to happen at once in the animation optional refinementnot all computers are set up for the same graphics speed in python one machine that use animates backandforth py quite well another seems to have the mouth wiggle on the latter sort of machineduring animation it is useful not to have visible screen changes for every individual move instead you can explicitly tell the computer when it is the right time to redraw the screen the computer can store changes and then update the screen withholding updates is controlled by win autoflush it starts as truebut can be changed to false before animation when set to falseyou must call update(every time you want the screen refreshed that is going to be just before the time sleep(in an animation in backandforth update py this is illustratedwith moveallonline replaced by moveallonlineupdate#new update versionadded win param def moveallonlineupdate(shapelistdxdyrepetitionsdelaywin)'''animate the shapes in shapelist along line in win move by (dxdyeach time repeat the specified number of repetitions have the specified delay (in secondsafter each repeat ''win autoflush false newset before animation for in range(repetitions)moveall(shapelistdxdyupdate(new needed to make all the changes appear time sleep(delaywin autoflush true newset after animation run the next example program backandforth py the final versionbackandforth py and its variantbackandforth update pyuse the observation that the code to make face embodies one unified ideasuggesting encapsulation inside function once you have encapsulated the code to make facewe can make several facesthen the problem with the original code for the face is that all the positions for the facial elements are hard-codedthe face can only be drawn in one position the full listing of backandforth py below includes makeface function with parameter for the position of the center of the face beneath the listing of the whole program is discussion of the individual changes'''test animation of group of objects making face combine the face elements in functionand use it twice have an extra level of repetition in the animation this version may be wobbly and slow on some machinesthen see backandforthflush py ''from graphics import import time def moveall(shapelistdxdy)''move all shapes in shapelist by (dxdy''for shape in shapelistshape move(dxdydef moveallonline(shapelistdxdyrepetitionsdelay)'''animate the shapes in shapelist along line graphics