[python] Convert a number range to another range, maintaining ratio