使用python 打印1 ~ 100 的奇数和偶数和
i=0
sum1=0
sum2=0
while i<=100:
if i%2==0:
sum1+=i
else:
sum2+=i
i+=1
print('偶数和为:%d' % sum1)
print('奇数和为:%d' % sum2)
i=0
sum1=0
sum2=0
while i<=100:
if i%2==0:
sum1+=i
else:
sum2+=i
i+=1
print('偶数和为:%d' % sum1)
print('奇数和为:%d' % sum2)