On my journey to learning PyMel, I wrote a simple bouncing ball animation script. Currently it generates far more frames than it needs to but incase it helps anyone, enjoy!
import pymel.core as pm;
from math import *
pm.newFile( force=True );
fps = 30;
animationLengthInSeconds = 10;
totalFrames = fps * animationLengthInSeconds;
numberOfBounces = 3.0;
startingAmplitude = 5.0;
PI = 3.14159;
groundY = 1.0;
obj = pm.polySphere(name="MySphere");
pm.autoKeyframe( state = True );
for currentFrame in range(1, totalFrames+1):
pm.currentTime(currentFrame, edit=True );
pm.setKeyframe();
t = float(currentFrame) / totalFrames;
currentAmplitude = (1.0-t)*startingAmplitude;
y = groundY + abs( sin( (t * PI) * numberOfBounces ) * currentAmplitude );
pm.move( 0,y,0, obj );