def clamp(x, min, max):
    """
    Returns x clamped between min and max.

    Returns min if x < min, returns max if x > max,
    returns x if min <= x <= max. Will return int if all arguments are int,
    will return float if any argument is float.

    Parameter x: The value to be clamped
    Precondition: x is an int or float

    Parameter min: The lower bound for the retun value
    Precondition: min is an int or float

    Parameter max: The upper bound for the reuturn value
    Precondition: max is an int or float
    """
    return min * (x < min) + max * (x > max) + x * (min <= x <= max)