Answer to Question #80039 in Python for Padhu

Question #80039
Write a function intreverse(n) that takes as input a positive integer n and returns the integer obtained by reversing the digits in n.

Here are some examples of how your function should work.

>>> intreverse(783)
387
>>> intreverse(242789)
987242
>>> intreverse(3)
3
1
Expert's answer
2018-08-23T04:35:23-0400
def intreverse(n):
res=0
while(n > 0):
lastDig = n %10
res = res *10 + lastDig
n = n //10
return res

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

Assignment Expert
23.08.18, 12:19

Dear Padhu, Questions in this section are answered for free. We can't fulfill them all and there is no guarantee of answering certain question but we are doing our best. And if answer is published it means it was attentively checked by experts. You can try it yourself by publishing your question. Although if you have serious assignment that requires large amount of work and hence cannot be done for free you can submit it as assignment and our experts will surely assist you.

Padhu
23.08.18, 12:13

Some thing to wrong in this program please correction

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS