def clamp(n, minn, maxn):
    """
    Clamp a value 'n' within the range 'minn' and 'maxn'.

    :param n:               value to be clamped
    :param minn:            lower bound of clamp
    :param maxn:            upper bound of clamp
    :returns:
        * **clamped_val** - value within the range of 'minn' and 'maxn'.

    """

    return min(max(n, minn), maxn)