''' In this exercise, you'll be simulating the movement of objects through 2D space, such as a bouncing ball as well as random diffusion. The code below simulates a ball moving from the left to the right side of the graphical window: ''' xSize = 800 ySize = 600 ballx = 1 bally = 300 dx = 1.0 nsteps = 1000 c = color().green screen = canvas("title", xSize, ySize) pen = writer(screen) for i in range(nsteps): ballx = ballx + dx pen.drawCircle(ballx, bally, 5, c, True) screen.update() screen.pause(5) screen.clear() screen.keepwindow() ''' Exercise A: Run the code above and observe the result. Then increase and decrease the speed at which the ball moves by modifying the value for `dx`. Exercise B: Extend the code such that the ball initially moves very fast, then gradually slows down before finally stopping at the right border of the graphical window, by making `dx` depend on the position of the ball within the graphical window. Exercise C: Extend the code such that the ball moves from top to bottom. Add a variable named `dy`. Exercise D: Extend the code such that the ball moves in a diagonal line over the graphical window. '''