Find largest digit in a number Dry Run in PYTHON

Find largest digit in a number is an interactive PYTHON dry run visualizer from the Recursion 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.

Find largest digit in a number Program Code

def largest_digit(n):
    if n < 10:
        return n
    last = n % 10
    max_in_rest = largest_digit(n // 10)
    return last if last > max_in_rest else max_in_rest

num = 739582
print(f"Number: {num}")
print(f"Largest digit = {largest_digit(num)}")

View the complete Recursion programs page.

Program Console Find largest digit in a number Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.