Code Examples
import json
from abc import ABC, abstractmethod
from datetime import datetime
# ── Custom Exceptions ─────────────────────────
class BankError(Exception): pass
class InsufficientFunds(BankError):
def __init__(self, need, have):
super().__init__...
import csv
from datetime import date
class InventoryError(Exception): pass
class OutOfStockError(InventoryError):
def __init__(self, name, want, have):
super().__init__(f"{name}: need {want}, only {have} in stock")
class ExpiredProductError(Inv...
import random, json
class DeadCharacterError(Exception): pass
class Item:
def __init__(self, name, effect, value):
self.name = name; self.effect = effect; self.value = value
def use(self, char):
if self.effect == "heal":
...