488 B
488 B
title, tags, expertise, author, firstSeen, lastUpdated
| title | tags | expertise | author | firstSeen | lastUpdated |
|---|---|---|---|---|---|
| Map number to range | math | beginner | maciv | 2020-10-04T12:43:57+03:00 | 2021-04-05T18:25:46+03:00 |
Maps a number from one range to another range.
- Return
nummapped betweenoutMin-outMaxfrominMin-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