Program Console Vignaankosh.com
Execution Panel
Console is empty.
Count number of digits in 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.
# Count number of digits in a number
num = int(input("Enter a number: "))
# Method 1: Using while loop (converted to string)
count = 0
temp = abs(num) # Handle negative numbers
for digit in str(temp):
count += 1
print(f"Number of digits in {num} = {count}")
# Method 2: Using mathematical approach
count_math = len(str(abs(num)))
print(f"Using len(): {count_math}")