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

Popular posts from this blog

Simple Python Program Code for Snake Game

Iris Flowers Classification ML Project with Code

Data exploration and scatter plot visualization in Python using Pandas and Matplotlib