1.代码
代码如下:
sum =0
for i in range(1, 101):
sum += i
i += 1
print('1到100的和为:',sum)
2.运行结果
D:\Python代码\Scripts\python.exe C:/Users/Lenovo/PycharmProjects/pythonFirstStart/实验二/demo9.py
1到100的和为: 5050
Process finished with exit code 0
代码如下:
sum =0
for i in range(1, 101):
sum += i
i += 1
print('1到100的和为:',sum)
D:\Python代码\Scripts\python.exe C:/Users/Lenovo/PycharmProjects/pythonFirstStart/实验二/demo9.py
1到100的和为: 5050
Process finished with exit code 0