def translate(value, leftMin, leftMax, rightMin, rightMax):
    leftSpan = leftMax - leftMin
rightSpan = rightMax - rightMin
valueScaled = float(value - leftMin) / float(leftSpan)
return rightMin + valueScaled * rightSpan
Mapping a range of values to another