请根据本题生成代码 “Calculate the sum from 1 to 1000”
时间: 2024-01-21 12:17:29 浏览: 52
汇编:1至1000循环累加
5星 · 资源好评率100%
下面是Python的代码实现:
```python
total = 0
for i in range(1, 1001):
total += i
print("The sum from 1 to 1000 is:", total)
```
输出结果为:
```
The sum from 1 to 1000 is: 500500
```
阅读全文