python中求1到100的和
>>> sum = 0
>>> for i in range(1,101): ## 利用for循环
sum += i
>>> print(sum)
5050
>>> del sum
>>> sum(list(range(1,101))) ## 利用sum函数
5050
>>> sum = 0
>>> i = 1
>>> while i < 101: ## while循环
sum += i
i += 1
>>> print(sum)
5050