所以我正在尝试制作一个医院模拟(基于文本)并且可以选择招募更多员工。我已经想出如何限制他们可以招募的次数(限制 350 名员工)并且他们获得的数量应该是随机的(random.choice(staffrec),但是一旦从 staffrec 生成随机数,它就会保持不变相同,我希望代码再次运行并产生不同的结果。这是我的代码。(抱歉,我已经把所有的都放了,所以我不会错过任何东西)
import time
import random
staff = 100
wards = 20
beds = 140
patients = 80
staffrec = [1, 2, 3, 4, 5, 6, 7, 8, 9]
staffrec = random.choice(staffrec)
option = ""
print("Welcome to Hospital Simulator!")
print("You have to manage the hospital with patients coming in,")
print("Staff recruitement and staff quitting,")
print("and how many beds and wards are available!")
Aopt = ["A", "a"]
Bopt = ["B", "b"]
Copt = ["C", "c"]
Dopt = ["D", "d"]
Eopt = ["E", "e"]
Fopt = ["F", "f"]
while staff <= 350:
staffrec = [1, 2, 3, 4, 5, 6, 7, 8, 9]
staffrec = random.choice(staffrec)
staff = staff + staffrec
while option != Fopt:
option = input("""What would you like to do:
A: View number of patients
B: View number of beds
C: View number of wards
D: View number of staff
E: Recruit more staff
F: Quit\n""")
if option in Aopt:
print("You currently have " + str(patients) + " patients\n")
if option in Bopt:
print("You currently have " + str(beds) + " beds\n")
if option in Copt:
print("You have " + str(wards) + " wards\n")
if option in Dopt:
print("You currently have " + str(staff) + " staff\n")
if option in Eopt:
print("You try and recruit more staff. You recruit " + str(staffrec) + " staff\n")
if staff > 350:
print("You cannot recruit any more staff!")
if option in Fopt:
print("Goodbye!")
break
还有其他与使用类的主题相关的帖子,但由于我是 python 的新手,所以我并不完全理解它们。:3 任何帮助将不胜感激!
一只萌萌小番薯
回首忆惘然
慕的地10843
相关分类