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

Project 01: Python Code for Music Recommendation with Explanation