标签:www 之间 代码 循环 html for tps 尊重 sum
sum1 = 0 for i in range(1,101): sum1 = sum1 + i i += 1 print(f"1-100之间的和是:{sum1}")
sum1 = 0 i = 1 while True: sum1 = sum1 + i if i == 100: break i += 1 print(sum1)
sum1 = 0 for i in range(1,101): if i % 2 == 0: sum1 = sum1 +i i += 1 print(f"1-100之间偶数的和是:{sum1}")
sum1 = 0 for i in range(1,101): if i % 2 != 0: sum1 = sum1 +i i += 1 print(f"1-100之间奇数的和是:{sum1}")
print(sum(range(1,101)))
尊重原创,本文转载自:https://www.cnblogs.com/pychina/p/10235884.html
python计算1~100的和,1~100奇数的和,1~100偶数的和,一条代码求1~100的和
标签:www 之间 代码 循环 html for tps 尊重 sum
原文地址:https://www.cnblogs.com/shouhu/p/13065378.html