def median(x):
    """Finds the median value of data set x"""
    x_sorted = sorted(x)
    mid = len(x) // 2

    if len(x) % 2 == 1:
        return x_sorted[mid]

    else:
        l = mid - 1
        h = mid
        return (x_sorted[l] + x_sorted[h]) / 2