#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/5/6 0006 10:25
# @Author : Anthony.Waa
# @Site :
# @File : 求1-100的所有数的和.py
# @Software: PyCharm
# demo1
# 定义基数
sum = 0
count = 1
# 循环开始
while count < 101:
sum += count
count += 1
print(sum)
# demo2
定义基数
sum = 0
# 循环开始
for count in range(1,101):
sum += count
print(sum)
# demo3
# 定义基数
sum = 0
count = 0
# 循环开始
while True:
if count == 100:
break
else:
count += 1
sum += count
print(sum)
转载于:https://www.cnblogs.com/ipyanthony/p/8998034.html