Answer to Question #259911 in Python for maitha

Question #259911

Write a method, reverseDigit, that takes an integer as a parameter and returns the number with its digits reversed. For example, the value of reverseDigit(12345) is 54321. Also, write a program to test your method. Call this method and print the results.


1
Expert's answer
2021-11-01T18:57:27-0400
N = 0   
def reverseDigit(num):  
    global N  
    if (num > 0):  
        Reminder = num % 10  
        N = (N * 10) + Reminder  
        reverseDigit(num // 10)  
    return N    
N = reverseDigit(12345)  
print("Reverse of the number is: %d" % N) 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog