center shape getcenter( center getx( center gety(if xlowdx -dx elif xhighdx -dx if ylowdy -dy elif yhighdy -dy time sleep(delaythe program starts the ball from an arbitrary point inside the allowable rectangular bounds this is encapsulated in utility function included in the programgetrandompoint the getrandompoint function uses the randrange function from the module random note that in parameters for both the functions range and randrangethe end stated is past the last value actually desireddef getrandompoint(xlowxhighylowyhigh)'''return random point with coordinates in the range specified '' random randrange(xlowxhigh+ random randrange(ylowyhigh+ return point(xythe full program is listed belowrepeating bounceinbox and getrandompoint for completeness several parts that may be useful lateror are easiest to follow as unitare separated out as functions make sure you see how it all hangs together or ask questions''show ball bouncing off the sides of the window ''from graphics import import timerandom def bounceinbox(shapedxdyxlowxhighylowyhigh)''animate shape moving in jumps (dxdy)bouncing when its center reaches the low and high and coordinates ''delay for in range( )shape move(dxdycenter shape getcenter( center getx( center gety(if xlowdx -dx elif xhighdx -dx if ylowdy -dy elif yhighdy -dy time sleep(delaydef getrandompoint(xlowxhighylowyhigh)'''return random point with coordinates in the range specified '' random randrange(xlowxhigh+ more on flow of control