How to calculate sum of n numbers in Python? To get sum of n numbers in Python program here we can add n numbers using for loop and then get the average by dividing it.

#### Sum and Average of n Numbers using Python :

```
number = int(input("Please Enter the Range : "))
sum = 0
value = 1
while (value <= number):
sum = sum + value
value = value + 1
average = sum / number
print("The Sum of Natural Numbers from 1 to %d = %d"%(number, sum))
print("Average of Natural Numbers from 1 to %d = %.2f"%(number, average))
```

## 0 comments:

## Post a Comment

Share your post related problems with us.