def quantile(x, percentile):
    """
    Returns value of specified quantile of X.

    :param list or tuple x: array to calculate Q value.
    :param float percentile: percentile (unit fraction).
    :return: Q value.
    :rtype: int or float
    :raise ValueError: when len of x == 0
    """
    if x:
        p_idx = int(percentile * len(x))
        return sorted(x)[p_idx]
    else:
        raise ValueError('len of x == 0')