How to calculate L2 norm in Python