def medianstat(n):
    """
    Calculates median for a list or tuple
    Modified from pg 347 Zelle's CS intro book,
    Python Programming, an Introduction to Computer Science
    """
    s = n[:]
    s.sort()
    size = len (n)
    midPos = size/2
    if size % 2 == 0:
        median = (s[midPos] + s[midPos - 1]) /2.0
    else:
        median = s[midPos]
    return median