SoFunction
Updated on 2024-11-16

python uses the range function to calculate the sum of a set of numbers

This article example describes how python uses the range function to calculate the sum of a set of numbers. Shared for your reference. Specific as follows:

sum = 0
numbers = range(1,10)
for i in numbers:
  sum += i
print(sum)

The result of the run is: 45

I hope that what I have described in this article will help you in your Python programming.