Program Console Vignaankosh.com
Execution Panel
Console is empty.
Find second smallest number is an interactive PYTHON dry run visualizer from the Tuples 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 second smallest in tuple
numbers = (62, 17, 84, 29, 95, 41, 17, 53)
print("Tuple:", numbers)
# Method 1: Using sorted
sorted_unique = tuple(sorted(set(numbers)))
if len(sorted_unique) >= 2:
print(f"Second smallest: {sorted_unique[1]}")
# Method 2: Single pass (float('inf') is positive infinity)
first = second = float('inf')
for num in numbers:
if num < first:
second = first
first = num
elif num < second and num != first:
second = num
print(f"Single pass: {second}")
# Note: float('inf') is used as initial value so any tuple element is < inf