#计算0~100之间所有数字的累计求和结果
#0.定义最终结果的变量
result = 0
#1.定义一个整数的变量记录循环的次数
i = 0
#2.开始循环
while i <= 100:
result += i
#处理计数器
i += 1
print(‘0~100之间所有数字的累计求和结果:%d’% result)
0~100之间所有数字的累计求和结果:5050
Process finished with exit code 0
#计算0~100之间所有数字的累计求和结果
#0.定义最终结果的变量
result = 0
#1.定义一个整数的变量记录循环的次数
i = 0
#2.开始循环
while i <= 100:
result += i
#处理计数器
i += 1
print(‘0~100之间所有数字的累计求和结果:%d’% result)
0~100之间所有数字的累计求和结果:5050
Process finished with exit code 0