num
mapped between outMin
-outMax
from inMin
-inMax
.def num_to_range(num, inMin, inMax, outMin, outMax): return outMin + (float(num - inMin) / float(inMax - inMin) * (outMax - outMin))
num_to_range(5, 0, 10, 0, 100) # 50.0
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️