How to multiply diagonal elements by each other using numpy?
You can use the numpy function diag to construct a diagonal matrix if you give it the intended diagonal as a 1D array as input. 
So you just need to create that, like [i**2 for i in range (N)] with N the dimension of the matrix.
For the purpose of this exercise, let's consider a matrix where the element m_{i, j} is given by the rule m_{i, j} = i*j if i == j and 0 else.
Is there an easy "numpy" way of calculating such a matrix without having to resort to if statements checking for the indices?