Program to calculate the sum of first 10 natural numbers using a while loop in Python:
# While loop in Python - Sum of first 10 natural numbers
num = 1
sum = 0
while num <= 10:
sum += num
num += 1
print("The sum of first 10 natural numbers is:", sum)
Comments
Post a Comment