Reverse a Given Number in Python – Programming, Pseudocode Example, C# Programming Example
Python 3

Reverse a Given Number in Python

This is a Python Program to reverse a given number.

The program takes a number and reverses it.

Here is the source code of the Python Program to reverse a given number.

Program Explanation

1. User must first enter the value and store it in a variable n.
2. The while loop is used and the last digit of the number is obtained by using the modulus operator.
3. The last digit is then stored at the one’s place, second last at the ten’s place and so on.
4. The last digit is then removed by truly dividing the number with 10.
5. This loop terminates when the value of the number is 0.
6. The reverse of the number is then printed.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: