Python Loops
Assignment
❏ Write a Python program to print all natural numbers from 1 to n. - using while loop
❏ Write a Python program to print all natural numbers in reverse (from n to 1). - using
while loop
❏ Write a Python program to print all alphabets from a to z. - using while loop
❏ Write a Python program to print all even numbers between 1 to 100.
❏ Write a Python program to print all odd numbers between 1 to 100.
❏ Write a Python program to find the sum of all natural numbers between 1 to n.
❏ Write a Python program to find the sum of all even numbers between 1 to n.
❏ Write a Python program to find the sum of all odd numbers between 1 to n.
❏ Write a Python program to print a multiplication table of any number.
❏ Write a Python program to count the number of digits in a number.
❏ Write a Python program to find the first and last digit of a number.
❏ Write a Python program to find the sum of the first and last digit of a number.
❏ Write a Python program to calculate the sum of digits of a number.
❏ Write a Python program to calculate the product of digits of a number.
❏ Write a Python program to enter a number and print its reverse.
❏ Write a Python program to check whether a number is palindrome or not.
❏ Write a Python program to find the frequency of each digit in a given integer.
2
❏ Write a Python program to enter a number and print it in words.
❏ Write a Python program to print all ASCII characters with their values.
❏ Write a Python program to find power of a number using a loop.
❏ Write a Python program to find all factors of a number.
❏ Write a Python program to calculate the factorial of a number.
❏ Write a Python program to find HCF (GCD) of two numbers.
❏ Write a Python program to find LCM of two numbers.
❏ Write a Python program to check whether a number is Prime number or not.
❏ Write a Python program to print all Prime numbers between 1 to n.
❏ Write a Python program to find the sum of all prime numbers between 1 to n.
❏ Write a Python program to find all prime factors of a number.
❏ Write a Python program to check whether a number is an Armstrong number or
not.
❏ Write a Python program to print all Armstrong numbers between 1 to n.
❏ Write a Python program to check whether a number is a Perfect number or not.
❏ Write a Python program to print all Perfect numbers between 1 to n.
❏ Write a Python program to check whether a number is a Strong number or not.
❏ Write a Python program to print all Strong numbers between 1 to n.
❏ Write a Python program to print Fibonacci series up to n terms.