In [5]:
def rotate(n,xs):
    return  xs[len(xs)-n:]+ xs[0:len(xs)-n]
In [6]:
rotate(4,[1,2,3,4,5,6])
Out[6]:
[3, 4, 5, 6, 1, 2]
In [7]:
rotate(6,xs = [1,2,3,4,5,6,7,8,9,10])
Out[7]:
[5, 6, 7, 8, 9, 10, 1, 2, 3, 4]
In [9]:
def chisqr(os,es):
    result = 0.0
    for i in range(len(os)):
        result = result + (os[i]-es[i])**2/es[i]
    return result
In [10]:
os = [2]*26  [2,2,2,2,...]
es = [1]*26  [1,1,1,1]
chisqr(os,es)
Out[10]:
26.0
In [ ]:
def chisqr_statistic(os,es):
    result = []
    for n in range(26):
        ???
    return result
In [11]:
min([4,3,5,6,1])
Out[11]:
1
In [13]:
[4,3,5,6,1].index(5)
Out[13]:
2
In [17]:
result = [ (2,'Red'),  (3,'Blue'),  (1,'Green') ]
result.sort()
print(result)
[(1, 'Green'), (2, 'Red'), (3, 'Blue')]
In [26]:
xs = []
for i in range(10):
    xs.append(i)
print(len(xs))
10000000
In [ ]: