Mapping a value in python
Revision as of 12:06, 20 March 2017 by Michael Murtaugh (talk | contribs)
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