Write a program in python to find the sum of first ten natural numbers.
Answers
Answered by
3
num = int(input("Enter a number: "))
if num < 0:
print("Enter a positive number")
else:
sum = 0
# use while loop to iterate un till zero
while(num > 0):
sum += num
num -= 1
print("The sum is",sum)
output in attachment
Attachments:
Similar questions
Social Sciences,
2 months ago
Math,
2 months ago
Social Sciences,
4 months ago
Math,
10 months ago
Political Science,
10 months ago
English,
10 months ago