Find sum of 1st 10 odd numbers using while loop in Python
while Loop - Question 1
In this question, we will see how to find the sum of 1st 10 odd numbers in Python programming using while loop. To know more about while loop click on the while loop lesson.
Q1) Write a program in Python to find the sum of 1st 10 odd numbers using while loop.
Program
i=1; n=1; s=0;
while i<=10:
print(n)
s=s+n
n=n+2
i=i+1
print('Sum of 1st 10 odd numbers = %d' %(s))
Output
1 3 5 7 9 11 13 15 17 19 Sum of 1st 10 odd numbers = 100