def rescale(X, lo, hi, new_lo, new_hi):
    """
    >>> rescale(0, 0, 1, 0, 1)
    0.0
    >>> rescale(1, 0, 1, 0, 1)
    1.0
    >>> rescale(0, -.5, .5, 0, 1)
    0.5
    >>> rescale(0.0, -1, 1, 1, 10)
    5.5
    """
    return (X-lo) / (hi-lo) * (new_hi - new_lo) + new_lo