Mapping a value in python
def map (v, inlow, inhigh, outlow, outhigh):
p = (float(v) - inlow) / inhigh
return outlow + (p * (outhigh - outlow))
Example: Maps the input value 50 from an input range of 0 - 100 to an output range of 2000 and 3000.
map(50, 0, 100, 2000, 3000) Out[2]: 2500.0