Python计算1到100的加和
print(sum(range(1,101)))
print(sum([x for x in range(1,101)]))
sum_value = 0
for i in range(1,101):
sum_value += i
print(sum_value)
结果:
5050
5050
5050
QQ:1061767621
Q群:215481318
print(sum(range(1,101)))
print(sum([x for x in range(1,101)]))
sum_value = 0
for i in range(1,101):
sum_value += i
print(sum_value)
结果:
5050
5050
5050