BASIC PYTHON PROGRAMS FOR ABSOLUTE BEGINNERS
PYTHON PROGRAM TO CHECK NUMBER IS PALIDROME OR NOT
LOGIC TO BE USED:
- Palidrome number is a number which when reversed remains unchanged.
- first find the reverse of the entered numnber.
- the equate it with the original number.
PROGRAM:
n=int(input("ENTER THE NUMBER TO FIND PALIDROME OF IT:"))
rev=0
temp=n
while(n>0):
a=n%10
rev=rev*10+a
n=n//10
if(temp==rev):
print("the number is palidrome ")
else:
print("the number is not palidrome")
INPUT OUTPUT OF THE PROGRAM:
ENTER THE NUMBER TO FIND PALIDROME OF IT:123456
the number is not palidrome
Tags:
codecademy