Lambda with conditional expressions Dry Run in PYTHON

Lambda with conditional expressions 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.

Lambda with conditional expressions Program Code

# Multiple condition lambda
grade = lambda score: "A" if score >= 90 else "B" if score >= 80 else "C" if score >= 70 else "D" if score >= 60 else "F"

# Age category
age_category = lambda age: "Child" if age < 13 else "Teen" if age < 20 else "Adult" if age < 65 else "Senior"

scores = [95, 82, 74, 68, 55, 45]
ages = [10, 15, 25, 35, 70, 80]

print("Score to Grade:")
for s in scores:
    print(f"  {s} → {grade(s)}")

print("\nAge to Category:")
for a in ages:
    print(f"  {a} → {age_category(a)}")

View the complete Special programs page.

Program Console Lambda with conditional expressions Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.