Program Console Vignaankosh.com
Execution Panel
Console is empty.
Reverse a number is an interactive PYTHON dry run visualizer from the For programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
# Reverse a number using string slicing
num = int(input("Enter a number: "))
# Method 1: Using string slicing
reversed_str = str(num)[::-1]
reversed_num = int(reversed_str)
print(f"Original: {num}")
print(f"Reversed: {reversed_num}")
# Method 2: Mathematical approach using reversed digit order
original = num
reversed_math = 0
for digit in str(num)[::-1]:
reversed_math = reversed_math * 10 + int(digit)
print(f"Using math: {reversed_math}")