1. 程式人生 > >python入門:求1-2+3-4+5...99的所有數的和

python入門:求1-2+3-4+5...99的所有數的和

== python入門 ... sta rt+ color python while style

1 start =1
2 sum =0
3 while start <100:
4     if start % 2 ==0:
5         sum =sum -start
6     else:
7         sum =sum + start
8     start =start+1
9 print(sum)

python入門:求1-2+3-4+5...99的所有數的和