0% found this document useful (0 votes)
23 views5 pages

02 Loop

Uploaded by

Dhrumi Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views5 pages

02 Loop

Uploaded by

Dhrumi Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

KICT – KRISHNA INSTITUTE OF COMPUTER TECHNOLOGY

PYTHON

Python Loop practice


1. Write a Python program to print all natural numbers from 1 to n
using a while loop.
2. Write a Python program to print all natural numbers in reverse order
from n to 1 using a while loop.
3. Write a Python program to print all alphabets from 'a' to 'z' using a
while loop.
4. Write a Python program to print all even numbers between 1 to 100
using a while loop.
5. Write a Python program to print all odd numbers between 1 to 100
using a while loop.
6. Write a Python program to find the sum of all natural numbers
between 1 to n using a while loop.
7. Write a Python program to find the sum of all even numbers between
1 to n using a while loop.
8. Write a Python program to find the sum of all odd numbers between
1 to n using a while loop.
9. Write a Python program to print the multiplication table of any
number using a while loop.
10. Write a Python program to count the number of digits in a
given number using a while loop.
11. Write a Python program to find the first and last digit of a
number using a while loop.
12. Write a Python program to find the sum of the first and last
digit of a number using a while loop.

www.kictindia.com Page | 1 Manav Patel Sir : +91-9909766990


KICT – KRISHNA INSTITUTE OF COMPUTER TECHNOLOGY

PYTHON
13. Write a Python program to swap the first and last digits of a
number using a while loop.
14. Write a Python program to calculate the sum of the digits of a
number using a while loop.
15. Write a Python program to calculate the product of the digits of
a number using a while loop.
16. Write a Python program to enter a number and print its reverse
using a while loop.
17. Write a Python program to check whether a number is a
palindrome or not using a while loop.
18. Write a Python program to find the frequency of each digit in a
given integer using a while loop.
19. Write a Python program to enter a number and print it in words
using a while loop.
20. Write a Python program to print all ASCII characters with their
values using a while loop.
21. Write a Python program to find the power of a number using a
for loop.
22. Write a Python program to find all factors of a number using a
while loop.
23. Write a Python program to calculate the factorial of a number
using a while loop.
24. Write a Python program to find the HCF (GCD) of two numbers
using a while loop.
25. Write a Python program to find the LCM of two numbers using
a while loop.
26. Write a Python program to check whether a number is a prime
number or not using a while loop.

www.kictindia.com Page | 2 Manav Patel Sir : +91-9909766990


KICT – KRISHNA INSTITUTE OF COMPUTER TECHNOLOGY

PYTHON
27. Write a Python program to print all prime numbers between 1
to n using a while loop.
28. Write a Python program to find the sum of all prime numbers
between 1 to n using a while loop.
29. Write a Python program to find all prime factors of a number
using a while loop.
30. Write a Python program to check whether a number is an
Armstrong number or not using a while loop.
31. Write a Python program to print all Armstrong numbers
between 1 to n using a while loop.
32. Write a Python program to check whether a number is a perfect
number or not using a while loop.
33. Write a Python program to print all perfect numbers between 1
to n using a while loop.
34. Write a Python program to check whether a number is a strong
number or not using a while loop.
35. Write a Python program to print all strong numbers between 1
to n using a while loop.
36. Write a Python program to print the Fibonacci series up to n
terms using a while loop.
37. Write a Python program to print Pascal's triangle up to n rows
using a for loop.
38. Write Python programs to print various star patterns using
while loops.
39. Write Python programs to print various number patterns using
while loops.
40. Write a Python program that asks the user for a positive integer
'n' and calculates the sum of all numbers from 1 to 'n'.

www.kictindia.com Page | 3 Manav Patel Sir : +91-9909766990


KICT – KRISHNA INSTITUTE OF COMPUTER TECHNOLOGY

PYTHON
41. Create a program that takes a list of numbers as input and
counts how many of them are even and how many are odd.
42. Design a program that prompts the user to enter the scores of
students. Determine and display their grades (A, B, C, D, or F) based
on the average score.
43. Write a script that simulates a password entry. Allow the user
three attempts to enter the correct password. If the correct password
is entered, print a success message; otherwise, display a failure
message.
44.Write a Python program that generates prime numbers within a given
range. Allow the user to input the range and then display the prime
numbers found.

www.kictindia.com Page | 4 Manav Patel Sir : +91-9909766990


KICT – KRISHNA INSTITUTE OF COMPUTER TECHNOLOGY

PYTHON

that sums up to the target. –


www.kictindia.com Page | 5 Manav Patel Sir : +91-9909766990

You might also like