Write a python program to find sum of first 10 natural numbers with output
Answers
Answered by
5
Answer:
Algorithm to calculate the sum and average of first n natural numbers
Allows a user to enter the number (n) he wishes to calculate the sum and average. ...
Next, run loop till the entered number using the for loop and range() function.
Next, calculate the sum using a sum = sum + current number formula.
Explanation:
Answered by
12
Answer:
The input number is 10
num = int(input("Enter the value of n: "))
hold = num
sum = 0
if num <= 0:
print("Enter a whole positive number!")
else:
while num > 0:
sum = sum + num
num = num - 1;
print("Sum of first", hold, "natural numbers is: ", sum)
So the output will be 55 (1+2+3+4+5+6+7+8+9+10).
Explanation:
Similar questions
Math,
2 months ago
Science,
2 months ago
Science,
2 months ago
Math,
4 months ago
Political Science,
4 months ago
English,
10 months ago
English,
10 months ago
CBSE BOARD X,
10 months ago