import random class Person: def __init__(self, name): self.name = name self.age = 0 self.happiness = 50 self.health = 50 self.intelligence = 50 self.money = 1000 self.is_alive = True def stats(self): print(f"\n{self.name}'s Stats:") print(f"Age: {self.age}") print(f"Happiness: {self.happiness}") print(f"Health: {self.health}") print(f"Intelligence: {self.intelligence}") print(f"Money: ${self.money}") def make_choice(self, choices): print("\nWhat would you like to do?") for i, choice in enumerate(choices, 1): print(f"{i}. {choice}") selected_choice = int(input("Enter your choice: ")) return selected_choice - 1 def random_event(self): events = [ ("You found money on the street!", "money", 500), ("You got sick!", "health", -20), ("You took an online course!", "intelligence", 10), ("You went on a vacation!", "happiness", 20), ("You had a car accident!", "health", -30), ("You won the lottery!", "money", 1000), ] event = random.choice(events) print(f"Event: {event[0]}") return event def update_life(self): self.age += 1 event = self.random_event() if event[1] == "money": self.money += event[2] elif event[1] == "health": self.health += event[2] elif event[1] == "intelligence": self.intelligence += event[2] elif event[1] == "happiness": self.happiness += event[2] if self.health <= 0: self.is_alive = False print(f"\n{self.name} has died at the age of {self.age}... Game Over!") def live_year(self): if self.is_alive: self.stats() self.update_life() choices = ["Work", "Study", "Relax", "Exercise"] selected = self.make_choice(choices) if selected == 0: self.money += 200 self.happiness -= 5 elif selected == 1: self.intelligence += 5 self.happiness -= 3 elif selected == 2: self.happiness += 10 self.health += 5 elif selected == 3: self.health += 10 self.happiness -= 3 # Prevent stats from going negative self.happiness = max(0, self.happiness) self.health = max(0, self.health) self.intelligence = max(0, self.intelligence) self.money = max(0, self.money) def start_game(): print("Welcome to Life Simulator!") name = input("Enter your name: ") person = Person(name) while person.is_alive and person.age < 100: person.live_year() start_game()