def c(matrix):
    result = numpy.zeros(matrix.shape)

    sums = numpy.zeros(matrix.shape[0])

    for i in range(matrix.shape[0]):
        for j in range(matrix.shape[1]):
            sums[i] += matrix[i, j]

    for i in range(matrix.shape[0]):
        for j in range(matrix.shape[1]):
            result[i, j] = matrix[i, j] / sums[i]

    return result

Goal of the code


Create a Result Array

result = numpy.zeros(matrix.shape)

Prepare an Array for the Row Sums

sums = numpy.zeros(matrix.shape[0])

Compute the Row Sums

for i in range(matrix.shape[0]):
    for j in range(matrix.shape[1]):
        sums[i] += matrix[i, j]