accounts = {}
def create_account():
num = input("Номер счёта: ").strip()
if num in accounts:
print("Счёт уже существует.")
return
owner = input("ФИО владельца: ").strip()
accounts[num] = {"owner": owner, "balance": 0.0, "history": []}
print(f"Счёт №{num} создан для {owner}.")
def show_balance():
num = input("Номер счёта: ").strip()
if num not in accounts:
print("Счёт не найден.")
return
acc = accounts[num]
print(f"№{num} | {acc['owner']} | Баланс: {acc['balance']:.2f} руб.")
def deposit():
num = input("Номер счёта: ").strip()
if num not in accounts:
print("Счёт не найден.")
return
try:
amount = float(input("Сумма пополнения: "))
if amount <= 0:
print("Сумма должна быть больше 0.")
return
accounts[num]["balance"] += amount
accounts[num]["history"].append(f"Пополнение: +{amount:.2f}")
print(f"Пополнено на {amount:.2f}. Баланс: {accounts[num]['balance']:.2f} руб.")
except ValueError:
print("Введите число.")
def withdraw():
num = input("Номер счёта: ").strip()
if num not in accounts:
print("Счёт не найден.")
return
try:
amount = float(input("Сумма снятия: "))
if amount <= 0:
print("Сумма должна быть больше 0.")
return
if amount > accounts[num]["balance"]:
print("Недостаточно средств.")
return
accounts[num]["balance"] -= amount
accounts[num]["history"].append(f"Снятие: -{amount:.2f}")
print(f"Снято {amount:.2f}. Баланс: {accounts[num]['balance']:.2f} руб.")
except ValueError:
print("Введите число.")
def transfer():
src = input("Со счёта №: ").strip()
dst = input("На счёт №: ").strip()
if src not in accounts or dst not in accounts:
print("Один или оба счёта не найдены.")
return
try:
amount = float(input("Сумма перевода: "))
if amount <= 0:
print("Сумма должна быть больше 0.")
return
if amount > accounts[src]["balance"]:
print("Недостаточно средств.")
return
accounts[src]["balance"] -= amount
accounts[dst]["balance"] += amount
accounts[src]["history"].append(f"Перевод на №{dst}: -{amount:.2f}")
accounts[dst]["history"].append(f"Перевод от №{src}: +{amount:.2f}")
print(f"Переведено {amount:.2f} со счёта №{src} на №{dst}.")
except ValueError:
print("Введите число.")
def show_history():
num = input("Номер счёта: ").strip()
if num not in accounts:
print("Счёт не найден.")
return
history = accounts[num]["history"]
if not history:
print("Операций пока нет.")
return
print(f"--- История счёта №{num} ---")
for entry in history:
print(f" {entry}")
while True:
print("\n1. Создать счёт 2. Баланс 3. Пополнить 4. Снять 5. Перевести 6. История 0. Выйти")
choice = input("Выбор: ").strip()
if choice == "1": create_account()
elif choice == "2": show_balance()
elif choice == "3": deposit()
elif choice == "4": withdraw()
elif choice == "5": transfer()
elif choice == "6": show_history()
elif choice == "0":
print("До свидания!")
break
else:
print("Неверный пункт меню.")