actions = { "1": "Serve beverages", "2": "Check seatbelts", "3": "Handle passenger request", "4": "Make PA announcement", "5": "Prepare for landing", "6": "Respond to emergency", "7": "View cabin status", "8": "End shift" } def print_slow(text, delay=0.03): for char in text: print(char, end='', flush=True) time.sleep(delay) print("\n")
def random_event(): events = [ {"text": "Turbulence hits!", "effect": lambda: setattr(cabin_status, 'turbulence', True) or print("Secure cabin immediately!")}, {"text": "A passenger starts shouting.", "effect": lambda: passengers.update({"random_seat": {"type": "angry", "needs": "complaint_about_delay"}})}, {"text": "Cabin temperature drops.", "effect": lambda: setattr(cabin_status, 'cabin_temp', 'cold')}, {"text": "Child starts crying loudly.", "effect": lambda: passengers.update({"row_19C": {"type": "child", "needs": "snack"}})}, ] if random.random() < 0.3: # 30% chance per loop event = random.choice(events) print_slow(f"\n⚠️ RANDOM EVENT: {event['text']}") event 'effect'
def handle_passenger(seat): if seat not in passengers: print(f"No passenger found at {seat}.") return p = passengers[seat] print(f"Approaching {seat} – {p['type']} passenger.") if p['needs'] == "reassurance": print("You calmly explain the situation. The passenger relaxes.") cabin_status['passenger_calm'] += 5 del passengers[seat] elif p['needs'] == "snack": print("You give the child a snack. They smile happily.") cabin_status['passenger_calm'] += 3 del passengers[seat] elif p['needs'] == "water": print("You bring water to the elderly passenger. They thank you.") cabin_status['passenger_calm'] += 4 del passengers[seat] elif p['needs'] == "complaint_about_delay": print("You listen patiently and offer a free drink voucher. The passenger calms down.") cabin_status['passenger_calm'] += 6 del passengers[seat] elif p['needs'] == "asthma_inhaler": print(" You retrieve the onboard first aid kit and assist with the inhaler. Passenger stabilizes.") cabin_status['medical_emergency'] = True cabin_status['passenger_calm'] -= 10 del passengers[seat] else: print("You try to help but the request is unclear. No effect.")
# CABIN CREW SIMULATOR v1.0 # A text-based simulation for flight attendants import time import random ------------------- GLOBAL DATA ------------------- cabin_status = { "seatbelt_sign": True, "cabin_temp": "normal", "turbulence": False, "medical_emergency": False, "passenger_calm": 80, # 0-100 "cabin_crew_morale": 85 }
passengers = { "row_12A": {"type": "anxious", "needs": "reassurance"}, "row_14C": {"type": "child", "needs": "snack"}, "row_22F": {"type": "elderly", "needs": "water"}, "row_08B": {"type": "angry", "needs": "complaint_about_delay"}, "row_30D": {"type": "medical", "needs": "asthma_inhaler"} }
def emergency_procedure(): print_slow("🚨 EMERGENCY! Prepare for evacuation commands.") print("1. Assume brace position") print("2. Shout 'Brace, Brace!'") print("3. Open exits when aircraft stops") choice = input("Choose correct step 1-3: ") if choice == "2": print_slow("✅ Correct! Passengers respond.") cabin_status['passenger_calm'] += 10 else: print_slow("❌ Wrong command. Chaos ensues. Simulation ends.") exit() def main(): print_slow("✈️ Welcome to Cabin Crew Simulator ✈️") print_slow("You are the Lead Flight Attendant on a Boeing 787.") print_slow("Manage cabin safety, passenger needs, and unexpected events.\n")
Select action: 2 Checking seatbelts. Everyone is secured.