今天,Python代码写的有点新意,晒一下
用eval
var('x,y,z')
f=x*y*z;
varlist=['x','y','z'];
ans=[eval('diff(f, ' + varlist[i] + ')') for i in range(3)];
def sumlist(l):
a=0;
for i in l:
a+=i;
return a;
ans=sumlist(ans);ans
今天,Python代码写的有点新意,晒一下
用eval
var('x,y,z')
f=x*y*z;
varlist=['x','y','z'];
ans=[eval('diff(f, ' + varlist[i] + ')') for i in range(3)];
def sumlist(l):
a=0;
for i in l:
a+=i;
return a;
ans=sumlist(ans);ans