In this post we see the python code to reverse the given number. we see what is Reverse number. If we are giving input as 1854 the program separates each and every integer no and rearrange it in a reverse manner and the result is 4581.
Program:
def reverse(Number):
Reverse= 0
while(Number > 0):
Reminder = Number %10
Reverse = (Reverse *10) + Reminder
Number = Number //10
print("\n Reverse of entered number is = %d" %Reverse)
Number = int(input("Please Enter any Number: "))
print(reverse(Number))
Output:
Please Enter any Number: 14897
Reverse of entered number is = 79841
The logic for this code is same like c and c++ language. So I'm not giving the explanation for this code. If you want explanation then write in comment box.
Python program to reverse the given integer number
Reviewed by Amit Waghmare
on
November 14, 2019
Rating:
No comments: