I try to be convenient with sum () in python, I understood the main function of sum, but as a mathematical backgroud, I was just inquisitive to know if we can use the sum in python in the same way as we do in mathematics, for example, consider this mathematical module:
Sq[a_, b_] := Module[{m, n}, m = Max[a, b]; n = Min[a, b];Sum[(m - r + 1) (n - r + 1), {r, 1, n}]]
Now, is it possible to record such an amount? I mean:
Sum[(m - r + 1) (n - r + 1), {r, 1, n}]
Trying to hide this in python, I am thinking of something like this:
sum((m - r + 1) (n - r + 1) in xrange(1,n+1))
but doesn't seem to work! so my question is how to make it work?
source share