Python实现简易ATM取款、存款、查余额操作。

name = None
money = 5000000

name = input("请输入姓名:")

def check_balance(boll):    # 余额查询
    if boll:
        print("---------------------余额---------------------")
    print(f"{name},您好,您的余额剩余:{money}")

def deposit():  # 存款
    print("---------------------存款---------------------")
    global money
    a = int(input("请输入存款数(元):"))
    print(f"{name},您好,您存款{a}元成功")
    money += a
    check_balance(False)

def withdraw_money():   # 取款
    print("---------------------取款---------------------")
    global money
    b = int(input("请输入取款数(元):"))
    print(f"{name},您好,您存款{b}元成功")
    money -= b
    check_balance(False)

def main():
    print("---------------------主菜单---------------------")
    print(f"{name},欢迎来到ATM,请选择操作:")
    print("查询余额\t[输入1]")
    print("存款\t\t[输入2]")
    print("取款\t\t[输入3]")
    print("退出\t\t[输入4]")
    return  int(input("请输入您的选择:"))

while True:
    fuuc = main()
    if fuuc == 1:
        check_balance(True)
        continue
    elif fuuc == 2:
        deposit()
        continue
    elif fuuc == 3:
        withdraw_money()
    else:
        print("退出成功")
        break


Python实现简易ATM取款、存款、查余额操作。_第1张图片

你可能感兴趣的:(Python学习日记,python,java,开发语言)