def clamp(value, min_value, max_value):
    """Clamps the given value between min and max"""
    if value > max_value:
        return max_value
    if value < min_value:
        return min_value
    return value