Home > Article > Backend Development > How to calculate the sum from 1 to 100 using python?
How to calculate the sum from 1 to 100 using python?
The code for python to calculate the sum of 1 to 100 is as follows:
sum = 0 for i in range(1,101): sum = sum + i print(sum)
Output result: 5050
Recommended tutorial: " Pyrhon video tutorial》
The above is the detailed content of How to calculate the sum from 1 to 100 using python?. For more information, please follow other related articles on the PHP Chinese website!