代码如下:def even_sum(num):result = 0for i in range(1,num + 1):if i % 2 == 0:result+= ireturn resultprint(even_sum(100))更简便的方法是使用列表推导 一行代码就行:print(sum([i for i in range(0,101,2 )]))