from functools import reduce
nums = list(range(1,101))
def jj(x):
a=0
if x%2==0:
return 0
else:
a += x**3
return a
l1 =list(map(jj,nums))
def sl(x,y):
return x+y
l2 = reduce(sl,l1)
print(l2)
不好意思上面忘记用filter了
from functools import reduce
nums = list(range(1,101))
def jj(x):
a=0
if (x+1)%2==0:
return x
l1 =list(filter(jj,nums))
def kk(x):
a=0
a += x ** 3
return a
b = list(map(kk,l1))
def sl(x,y):
return x+y
l2 = reduce(sl,b)
print(l2)