FallTime Python Program

from visual import *
scene.background=(1,1,1)
scene.autoscale=1
floor = box(length=1.0, height=0.05, width=1.0, color=color.blue)
trail=curve()
rad = 0.021
ball = sphere(pos=(0,1,0), radius=rad, color=color.red)
ball.velocity = vector(0,-1,0)
scene.autoscale=0
falltime = 0.0
dt = 0.005
while 1:
  rate(100)
  if (ball.velocity.y < 0.0):
  falltime = falltime + dt
  ball.pos = ball.pos + ball.velocity*dt
  if ball.y < rad:
    print "Falltime = ",falltime
    falltime = 0.0
    ball.velocity.y = -ball.velocity.y
  else:
    ball.velocity.y = ball.velocity.y - 9.8*dt
    trail.append(pos=ball.pos, color=(0,0.9,0))