def median_val(vals):
    """
    :param vals: an iterable such as list
    :return: the median of the values from the iterable
    """
    n = len(vals)
    sorted_vals = sorted(vals)
    if n % 2 == 0:
        return (sorted_vals[n // 2] + sorted_vals[n // 2 - 1]) / 2
    else:
        return sorted_vals[n // 2]