from fractions import Fraction

arr = [[1, 1, 1, 1, 0, 0, 1, 0, 0, 0] ,
[1, 1, 1, 0, 1, 0, 0, 1, 0, 1] ,
[1, 1, 1, 0, 0, 1, 0, 0, 1, 0] ,
[1, 0, 0, 1, 1, 1, 1, 0, 0, 1] ,
[0, 1, 0, 1, 1, 1, 0, 1, 0, 1] ,
[0, 0, 1, 1, 1, 1, 0, 0, 1, 1] ,
[1, 0, 0, 1, 0, 0, 1, 1, 1, 0] ,
[0, 1, 0, 0, 1, 0, 1, 1, 1, 1] ,
[0, 0, 1, 0, 0, 1, 1, 1, 1, 0]]


def gauss(arr):
    n, m = len(arr), len(arr[0])
    h, k = 0, 0
    while h < n and k < m:
        idx = next((i for i in range(h, n) if arr[i][k] != 0), None)
        if idx is None:
            k += 1
        else:
            arr[idx], arr[h] = arr[h], arr[idx]
            for i in range(h + 1, n):
                f = arr[i][k] / arr[h][k]
                arr[i][k] = 0
                for j in range(k + 1, m):
                    arr[i][j] -= arr[h][j] * f
            h += 1
            k += 1
    return arr

gauss(arr)
for x in arr:
    print(x)

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: