Programming Examples

Python program to create a function for reverse the number


Write a python program to create a function which reverse the given number

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)
print("Reverse of Number is : ",ans)
Output

Enter any Number 2345

Reverse of Number is :  5432

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad