Python语言计算1+2+3+4,用while循环for循环分别实现

Python语言计算1+2+3+4,用while循环for循环分别实现Python语言计算1+2+3+4,用while循环for循环分别实现Python语言计算1+2+3+4,用while循环for循环分别实现Python语言计算1+2+3+4,用while循环for循环分别实现Python语言计算1+2+3+4,用while循环for循环分别实现

i = 0
s1 = 0
s2 = 0
while i <= 100:
if i % 2 == 0:
s1 += i
else:
s2 += i
i += 1
print("100以内的偶数和为:%d" % s1)
print("100以内的奇数和为:%d" % s2)

s3 = 0
s4 = 0
for i in range(0, 100+1, 2):
s3 += i
for i in range(1, 100, 2):
s4 += i
print("100以内的偶数和为:%d" % s3)
print("100以内的奇数和为:%d" % s4)