def rescale(num, old_min, old_max, new_min, new_max):
    """
    Rescale num from range [old_min, old_max] to range [new_min, new_max]
    """
    old_range = old_max - old_min
    new_range = new_max - new_min
    new_val = new_min + (((num - old_min) * new_range)/old_range)

    return new_val