A diagonal matrix carries numbers down its main diagonal and zeros everywhere else. Given a list of n values, build the n × n matrix that holds them.
Task: write make_diagonal(values) returning that matrix as a list of rows.
values[i] goes at row i, column i. Every other entry is 0.len(values) rows, each len(values) long.0 for the empty slots.These matrices are worth recognising because multiplying by one is just scaling each coordinate independently — the first axis by the first value, the second by the second, with nothing mixing between them. That's why the identity matrix is diagonal with all ones (scale everything by 1, i.e. change nothing), and why a zero on the diagonal flattens that axis away for good, which is exactly when a matrix stops being invertible.