def is_k_bounded(ptn, k):
    """ Returns ``True`` if and only if the partition ``ptn`` is bounded by ``k``.

    EXAMPLES::

        sage: is_k_bounded(Partition([4, 3, 1]), 4)
        True
        sage: is_k_bounded(Partition([4, 3, 1]), 7)
        True
        sage: is_k_bounded(Partition([4, 3, 1]), 3)
        False
    """
    if ptn.is_empty():
        least_upper_bound = 0
    else:
        least_upper_bound = max(ptn)
    return least_upper_bound <= k
