coding the matrix by Python