guyss plss tell me python coding to find the sum of first 10 natural numbers
plsss
Answers
Answer:
nu
TUTORIALS
EXAMPLES
GET APP
Python Program to Find the Sum of Natural Numbers
In this program, you'll learn to find the sum of n natural numbers using while loop and display it.
To understand this example, you should have the knowledge of the following Python programming topics:
Python if...else Statement
Python while Loop
In the program below, we've used an if...else statement in combination with a while loop to calculate the sum of natural numbers up to num.
Source Code
# Sum of natural numbers up to num
num = 16
if num < 0:
print("Enter a positive number")
else:
sum = 0
# use while loop to iterate until zero
while(num > 0):
sum += num
num -= 1
print("The sum is", sum)....
if if the answer helps you please make me as brand list..
Answer:
Hi
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)
pls mark me brainliest and if you liked my answer pls follow me
thnq
_________