
python
import random
def temp(x):
if x<=37.5:
print(f"您的体温是:{x},体温正常请进")
else:
print(f"您的体温是:{x},需要隔离")
x=random.randint(35,45)
temp(x)


python
def find():
"""
查询余额函数
直接查询全局变量money的值并返回
:return:
"""
global money
print(f"账户还有:{money}")
return money
def store(storemoney):
"""
实现存款操作
:param storemoney: 本次需要存入的金额
:return: 存款后账户内的钱
"""
global money
money=storemoney+money
print(f"存钱后的账户金额为:{money}")
return money
def out(outmoney):
"""
实现取款操作
:param outmoney:取出的金额
:return: 取出后的金额
"""
global money
if money>=outmoney:
money=money-outmoney
print(f"取钱后的账户金额为:{money}")
else:
print("金额不足")
return money
def main():
"""
实现页面的主函数
:return:
"""
step1=input("当前需要执行的操作:")
while True:
if step1=='查询余额':
find()
main()
elif step1=='存款':
storemoney=input("此次存款的金额:")
storemoney=float(storemoney)
store(storemoney)
main()
elif step1=='取款':
outmoney=input("此次取款的金额:")
outmoney=float(outmoney)
out(outmoney)
main()
else:
print("欢迎下次使用")
break
money=5000000
name=input("请输入你的姓名:")
main()

在该程序中,要注意break语句的位置,决定结束的是哪一个循环,在函数中,如果要使用或者修改全局变量的值,要在函数中用global声明该全局变量,即global xxx,即可正常使用。