Programs of while loop in Python
Q1. Write a program to print the following using while loop
a. First 10 Even numbers
b. First 10 Odd numbers
c. First 10 Natural numbers
d. First 10 Whole numbers
Q2. Write a program to print first 10 integers and their squares using while loop.
11
24
3 9 and so on
Q3. Write for loop statement to print the following series:
10, 20, 30 … … 300
Q4. Write a while loop statement to print the following series
105, 98, 91 ………7.
Q5. Write a program to print first 10 natural number in reverse order using while
loop.
Q6. Write a program to print sum of first 10 Natural numbers.
Q7. Write a program to print sum of first 10 Even numbers.
Q8. Write a program to print table of a number entered from the user.
Q9. Write a program to find the sum of all even numbers that falls between two
numbers (exclusive both numbers) entered from the user using while loop.
Q10. Write a program to check whether a number is prime or not using while loop.
Q11. Write a program to find the sum of the digits of a number accepted from the
user.
Q12. Write a program to find the product of the digits of a number accepted from
the user.
Q13. Write a program to reverse the number accepted from user using while loop.
Q14. Write a program to display the number names of the digits of a number
entered by user, for example if the number is 231 then output should be Two Three
One
Q15. Write a program to print the Fibonacci series till n terms (Accept n from user)
using while loop.
Q16. Write a program to print the factorial of a number accepted from user.
Q17. Write a program to check whether a number is Armstrong or not. (Armstrong
number is a number that is equal to the sum of cubes of its digits for example : 153
= 1^3 + 5^3 + 3^3.)
Q18. Write a program to enter the numbers till the user wants and at the end it
should display the sum of all the numbers entered.
Q19. Write a program to enter the numbers till the user enter ZERO and at the end
it should display the count of positive and negative numbers entered.
Q20. Write a program to find the HCF of two numbers entered from the user.
Q21. Write a program to check whether a number is palindrome or not.
Q22. Write a program to accept 10 numbers from the user and display it’s average
Q23. Write a program to accept 10 numbers from the user and display the largest
& smallest number number.
Q24. Write a program to display sum of odd numbers and even numbers separately
that fall between two numbers accepted from the user.(including both numbers)
using while loop.
Q25. Write a program to display all the numbers which are divisible by 13 but not
by 3 between 100 and 500.(exclusive both numbers)
Q26. Write a program to print the following series till n terms.
2 , 22 , 222 , 2222 _ _ _ _ _ n terms
Q27. Write a program to print the following series till n terms.
1 4 9 16 25 _ _ _ _ _ n terms.
Q28. Write a program to find the sum of following series
1 + 8 + 27 …………n terms
Q29. Write a program to find the sum of following series:
1 + 2 + 6 + 24 + 120 . . . . . n terms
Q30. Write a program to find the sum of following series:
S = 1 + 4 – 9 + 16 – 25 + 36 – … … n terms
Q31. Write a Program to print all the characters in the string ‘PYTHON’ using
while loop.
Q32. Write a program to print only odd numbers from the given list using while
loop. L = [23, 45, 32, 25, 46, 33, 71, 90]
Q33. Write a program to print all the factors of a number using for loop.
Q34. Write a python program to get the following output
1—–49
2—–48
3—–47
..
..
..
48—–2
49—–1
NOTE : The Questions which are highlighted with red colour those questions we
will do later because those questions are from LIST and DICTIONARY. You
don’t have to do those question now.