import numpy as np def sum_matrix(N): my_matrix = np.diag(np.arange(N-1, -1, -1), k=0) return *** print(sum_matrix(5)) print(sum_matrix(10)) print(sum_matrix(15)) Create in Numpy a diagonal matrix with elements from N to 0. Count the sum of its values on the diagonal.
import numpy as np def sum_matrix(N): my_matrix = np.diag(np.arange(N-1, -1, -1), k=0) return sum(my_matrix.diagonal()) print(sum_matrix(5)) print(sum_matrix(10)) print(sum_matrix(15))