Python入门:求1-2+3-4+5...99的所有数的和

 num =1
sum =0
while num <=99:
if num % 2 ==1:
sum = sum + num
num =num +1
print(sum)

2.求1-2+3-4+5...99的所有数的和

 num =1
sum =0
while num <=99:
if num % 2 ==1:
sum = sum + num
else:
sum =sum -num
num =num +1
print(sum)
上一篇:mysql中的JOIN用法总结


下一篇:eclipse以O开头的版本安装tomcat插件