(items, q)
return items[index]
Compute the q-th percentile of the elements in 'items' by nearest-rank

    :param items: pre-sorted array of numbers

    >>> percentile([15, 20, 35, 40, 50], .05)
    15
    >>> percentile([15, 20, 35, 40, 50], .3)
    20
    >>> percentile([15, 20, 35, 40, 50], .4)
    20
    >>> percentile([15, 20, 35, 40, 50], .5)
    35
    >>> percentile([3, 10], .5)
    3
    >>> percentile([], .5)
Compute the q-th percentile of the elements in 'items' by nearest-rank
Compute the q - th percentile of the elements in items by nearest - rank
def percentile(items, q):
    """
    Compute the q-th percentile of the elements in 'items' by nearest-rank

    :param items: pre-sorted array of numbers

    >>> percentile([15, 20, 35, 40, 50], .05)
    15
    >>> percentile([15, 20, 35, 40, 50], .3)
    20
    >>> percentile([15, 20, 35, 40, 50], .4)
    20
    >>> percentile([15, 20, 35, 40, 50], .5)
    35
    >>> percentile([3, 10], .5)
    3
    >>> percentile([], .5)
    """
    if not items:
        return None
    index = ceil(q * len(items)) - 1
    return items[index]
def percentile ( items , q ) : if not items : return None index = ceil ( q * len ( items ) ) - 1 return items [ index ]