def translate(value, from_min, from_max, to_min, to_max):
    """
    Translates the value passed as a parameter into a corresponding value
    in the right range.
    """
    # Figure out how 'wide' each range is
    left_span = from_max - from_min
    right_span = to_max - to_min

    # Convert the left range into a 0-1 range (float)
    value_scaled = float(value - from_min) / float(left_span)

    # Convert the 0-1 range into a value in the right range.
    return to_min + (value_scaled * right_span)