# Not just values — conditions too
# match / case with guards — pattern + condition

# ─────────────────────────────────────────────
# Guards in action
# ─────────────────────────────────────────────

score = int(input("Enter your score: "))

match score:
    case n if n >= 90:
        print("Excellent.")
    case n if n >= 70:
        print("Good.")
    case n if n >= 60:
        print("Passed.")
    case _:
        print("Failed.")

# n captures the value of score
# guard adds the condition — both must be True

# ─────────────────────────────────────────────
# Matching on type
# ─────────────────────────────────────────────

value = input("Enter something: ")

match value:
    case v if v.isdigit():
        print(f"{v} is a number.")
    case v if v.isalpha():
        print(f"{v} is a word.")
    case _:
        print("Mixed or unknown.")

# ─────────────────────────────────────────────
# Guards with multiple conditions
# ─────────────────────────────────────────────

age = int(input("Enter your age: "))
has_id = input("Do you have ID? (y/n): ")

match age:
    case n if n >= 18 and has_id == "y":
        print("Access granted.")
    case n if n >= 18 and has_id != "y":
        print("ID required.")
    case _:
        print("Access denied — too young.")

# guards combine with and, or, not — just like if

# ─────────────────────────────────────────────
# match vs if / elif
# ─────────────────────────────────────────────

command = input("Enter command: ")

# match — clean for one variable, many values
match command:
    case "quit" | "exit":
        print("Leaving.")
    case "help":
        print("Help.")
    case _:
        print("Unknown.")

# if / elif — better for complex, unrelated conditions
# if score > 90 and attendance > 80:
#     print("Honours.")
# elif score > 60:
#     print("Passed.")

# ─────────────────────────────────────────────
# Quick reference
# ─────────────────────────────────────────────

# match value:
#     case n if condition:   — n captures value, guard adds condition
#         block
#     case _:                — wildcard, always last
#
# guards use and, or, not — same as if
# match for one variable — if/elif for complex logic
