Program Console Vignaankosh.com
Execution Panel
Console is empty.
Sort tuples using lambda as key is an interactive PYTHON dry run visualizer from the Special 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.
# List of tuples (name, age, score)
students = [("Alice", 22, 85), ("Bob", 19, 92), ("Charlie", 21, 78), ("Diana", 20, 95)]
# Sort by age (second element)
by_age = sorted(students, key=lambda x: x[1])
# Sort by score (third element) descending
by_score = sorted(students, key=lambda x: x[2], reverse=True)
print("Sorted by age:", by_age)
print("Sorted by score (highest first):", by_score)