# Tuple Mini Project — Temperature Converter
# conversion formulas stored in tuples, looked up by mode
# redhorndev.com

# ─────────────────────────────────────────────
# Setup — each conversion is a tuple
# (label, from_unit, to_unit, formula)
# ─────────────────────────────────────────────

conversions = {
    "1": ("Celsius to Fahrenheit", "°C", "°F", lambda c: c * 9/5 + 32),
    "2": ("Fahrenheit to Celsius", "°F", "°C", lambda f: (f - 32) * 5/9),
    "3": ("Celsius to Kelvin",     "°C", "K",  lambda c: c + 273.15)
}

# ─────────────────────────────────────────────
# Menu
# ─────────────────────────────────────────────

print("1 — Celsius to Fahrenheit")
print("2 — Fahrenheit to Celsius")
print("3 — Celsius to Kelvin")
mode = input("Mode: ")

# ─────────────────────────────────────────────
# Lookup, unpack, convert
# ─────────────────────────────────────────────

if mode in conversions:
    label, from_unit, to_unit, formula = conversions[mode]  # unpack tuple
    temp = float(input(f"Temperature ({from_unit}): "))
    result = formula(temp)                                   # apply formula
    print(f"\n{temp}{from_unit} = {result:.1f}{to_unit}")
else:
    print("Invalid mode.")
