MSBTE Python Loop-Based Program Questions (50 Questions)
For Loop Programs (1-20)
1. Print numbers from 1 to 10.
2. Print even numbers between 1 to 50.
3. Print odd numbers from 1 to 100.
4. Print the multiplication table of a number.
5. Calculate factorial of a number.
6. Calculate the sum of numbers from 1 to N.
7. Print reverse of a number.
8. Count digits in a number.
9. Check if a number is prime.
10. Print all prime numbers from 1 to 100.
11. Generate Fibonacci series up to N terms.
12. Print squares of numbers from 1 to N.
13. Find sum of digits of a number.
14. Check if a number is palindrome.
15. Print all Armstrong numbers between 1 and 500.
16. Print characters of a string one by one.
17. Find ASCII value of each character in a string.
18. Print sum of even and odd numbers between 1 and 50.
19. Find the power of a number (x^y).
20. Find GCD (HCF) of two numbers using loop.
While Loop Programs (21-40)
21. Print numbers from 1 to 10 using while loop.
22. Reverse a number using while loop.
23. Count number of digits in a number.
24. Calculate factorial using while loop.
25. Print sum of digits using while loop.
26. Check if a number is palindrome using while loop.
27. Check if a number is an Armstrong number using while loop.
28. Find LCM of two numbers using while loop.
29. Accept numbers until user enters 0 and print sum.
30. Accept numbers until negative number is entered.
31. Print Fibonacci series using while loop.
32. Accept password until it is correct (simulate login).
33. Print alphabets A to Z using while loop.
34. Find average of N numbers entered by the user.
35. Count vowels in a string using while loop.
36. Count frequency of digit 5 in a number.
37. Accept and sum 5 numbers using while loop.
38. Calculate power of number (x^y) without using **.
39. Convert a decimal number to binary using while loop.
40. Sum of even digits of a number using while loop.
Nested Loop Programs (41-50)
41. Print the following pattern:
**
***
****
42. Print pattern:
12
123
1234
43. Print multiplication table from 1 to 5 using nested loops.
44. Print pattern of numbers:
54321
4321
321
21
45. Print pyramid of stars.
46. Print Floyd's triangle.
47. Print pattern:
AB
ABC
ABCD
48. Print table of all numbers from 1 to 10.
49. Count number of words in a sentence using nested loop.
50. Print prime numbers in 2D matrix format using nested loop.