# 黑马ATM
money = 5000000
name = "杨大帅"
def check_money():
print("查询余额,请稍等")
print(f"余额还剩余{money}元")
main_menu()
def restore_money():
re_money = int(input("请输入存款金额(元):"))
global money
money += re_money
print(f"目前余额剩余{money}")
main_menu()
def withdraw_money():
wi_money = int(input("请问你要取多少钱(元):"))
global money
if money < wi_money:
print("余额不足,请重新输入")
withdraw_money()
money -= wi_money
print(f"目前余额剩余{money}元")
main_menu()
name1 = input("请输入用户名:")
def main_menu():
global name1
if name == name1:
print("欢迎进入黑马ATM")
print("请输入您想进行的操作")
a = int(input("1查询余额,2存钱,3取钱"))
if a == 1:
check_money()
if a == 2:
restore_money()
if a == 3:
withdraw_money()
else:
print("选择错误,退出程序中")
exit()
else:
print("用户名或选项输入错误,程序退出")
main_menu()
运行效果