Program to check given number is palindrome or not.

In this python basic program we will check whether the given number is palindrome or not.

Steps to solve the program
  1. Take a number as input through the user and create a variable rev and assign its value equal to 0.
  2. Use a while loop to find the reverse of a number.
  3. While num is greater than 0 divide the number by 10 using % to find the remainder.
  4. Multiply the rev by 10 and add the remainder to it.
  5. Now divide the number by 10 using //.
  6. If the reversed number is equal to the input number then it is a palindrome.
				
					n = num = int(input("Enter a number: "))
rev = 0

while n>0:
    rem = n%10
    rev = rev*10+rem
    n = n//10
    
if num == rev:
    print("Given number is a palindrome number")
else:
    print("Given number is not a palindrome number")
				
			

Output :

				
					Enter a number: 121
Given number is a palindrome number
				
			

Fibonacci series between 0 to 50.

calculate compound interest.

Leave a Comment