# code for Numpy tutorial
      
# numpy tutorial
        
        import numpy as np
        
        ma = np.array([1,2,3,4,5,6,7,8,9,10])
        print(ma)
        
        # divide into two groups
        
        half = len(ma)//2
        mb = ma.reshape(2,half)
        print(mb)
        
        # sum
        mc = np.sum(mb)
        print(mc)
        mc = np.sum(mb,axis=1)
        print(mc)
        
        mcol = mb[::,::2]
        print(mcol)
        
        mc2 = mb[::,1::2]
        print(mc2)
        
        mlarge = mb[mb > 5]
        print(mlarge)
        
        modd = mb[mb%2 == 1]
        print(modd)
        
        mrev = mb[::,::-1]
        print(mrev)
        
        mrev2 = mb[::-1,::]
        print(mrev2)
        
        mbig = np.array([ma,ma])
        print(mbig)
        
        mbt = mbig.T
        print(mbt)
        
        # get col from bottom to top, column c
        
        print(mb)
        b2t = mb[::-1,::]
        bx = b2t[::,2]
        print(bx)
        
        # get odd rows
        
        mc = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]])
        oddrow = mc[1::2,::]
        print(oddrow)
        
        # get even row last col
        
        evenrow = mc[::2,::]
        print(evenrow)
        lastcol = evenrow[::,-1]
        print(lastcol)
        
        # get diagonal
        
        md = np.array([[1,2,3],[4,5,6],[7,8,9]])
        i = np.identity(len(md),int)
        dia = md*i
        print(dia)
        
        # exercise slide 45, student score, who is lower than average
        
        data = np.array([[610011,80,90,70],
                        
        [610022,50,80,68],
                        
        [610033,70,85,80],
                        
        [610044,60,50,90],
                        
        [610055,90,74,70]])
        print(data)
        datascore = data[::,1:]
        print(datascore)
        w = np.array([[0.3,0.5,0.2]])
        score = datascore * w
        print(score)
        total = score.sum(axis=1)
        print(total)
        avg = total.mean()
        print(avg)
        x = total[total < avg]
        print(x)
        print(data[total < avg])