#!/usr/bin/python3

print("Content-Type: text/html  \n")    #required

print("""
<html>
<body>
<table border="3">
<caption>Analytics</caption>
<tr>
<th>list number</th>
<th>num of elements</th>
<th>sum</th>
<th>average</th>
<th>min</th>
<th>max</th>
<th>median</th>
<th>mode</th>
<th>stdev</th>
</tr>""")

import statistics

def analytic(numList):
    try:
        result ={'count':len(numList), 'sum':sum(numList), 'avg':(sum(numList)/len(numList)),
                 'min':min(numList), 'max':max(numList), 'median':statistics.median(numList),
                 'mode':statistics.mode(numList), 'stdev':statistics.stdev(numList)}
        return result
    except:
        print('No unique mode found ', numList, '<b>')
    
numList0 = [-2,9,0,46,8,-10,12,3,-99,99,22,1,-6,-8,-5]
numList1 = [-1,-2,-38,8,20,22,3,4,-11,20,4,0,6,-77,12]
numList2 = [1,2,3,-4,-5,45,-99,7,5,66,-2,-23,-6,55,0]
numList3 = [9,88,-88,-99,-55,-1,2,-2,0,66,44,123,4,-5,-7]
numList4 = [3,98,-89,-4,-7,-66,91,38,54,0,2,5,9,-2,4]

numList0.sort()
numList1.sort()
numList2.sort()
numList3.sort()
numList4.sort()

numLists = [numList0,numList1,numList2,numList3,numList4]
                  

def slice(numLists, index):
    column = []
    for row in numLists:
        column.append(row[index])
    return column

for x in range (len(numLists[0])):
    sliced_column = slice(numLists, x)
    column_analytic = analytic(sliced_column)
    print(F"""<tr>
<td>{x}</td>""")
    for (key, value) in column_analytic.items():
         print(F"<td>{value}</td>")
    print("</tr>")

print ("""</table>
</body>
</html>""")