Learning Scientific Programming with Python (2nd edition)
P4.3.1: Matrix trace
Question P4.3.1
Use a list comprehension to calculate the trace of the matrix M (that is, the sum of its diagonal elements).
Hint: the sum built-in function takes an iterable object and sums its values.