Programming Examples

Python program to check number is Palindrome or not using function


Write a Python program to input any number and check number is Palindrome or Not using Function

Solution

def reverse(num):
    rev=0
    while num>0:
        rev=rev*10+(num%10)
        num=num//10
    return rev
num=int(input("Enter any Number "))
ans=reverse(num)
if num==ans:
    print("Number is Palindrome ")
else:
    print("Number is Not Palindrome")
Output/ Explanation:

Enter any Number 5245

Number is Not Palindrome

>>> 

=================== 

Enter any Number 10001

Number is Palindrome 

>>> 

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad