猫史档案馆


【Python作品分享】VirusSimulate【作品秀】

用户:思考中的编程者772思考中的编程者772查看:0 回复:0 评论:0 创建时间:2020-04-10T09:14:28


【作品展示】

center_image

 

【作品介绍】

别管图片

病毒模拟程序

参数:人口 初始病人 每日喵亡率 每日治愈率 每日传染数

 

【作品源代码】

# Import
import time
# Ask Population,StartingPatient(SP),SingleDayDeathPossibility(SDDP),SingleDayHealingPossibility(SDHP),R-O
Population = int(input('Please enter total population:'))
SP = int(input('Please enter Starting patient:'))
SDDP = float(input('Please enter the possibility of a patient dying in any day(in decimals, such as 0.01(1%):'))
SDHP = float(input('Please enter the possibility of a patient healing in any day(in decimals, such as 0.01(1%):'))
RO = float(input('Please enter the average number of people that can a patient can infect each day:'))
# Confirm
if SDDP >= 1.01 or SDHP >= 1.01 or SDDP <= 0 or SDHP <= 0:
    print("")
    print("._. Your virus has really weird syptoms on people......")
    time.sleep(3)
    input("Press enter to quit")
if SP >= Population or RO >= Population:
    print("")
    print("Wow...... Ghost Patients.......")
    time.sleep(3)
    input("Press enter to quit")
# Simulate
a = 0
while True:
    if Population <= 0:
        print("KO  Virus Win")
        break
    if SP <= 0:
        print("KO HUMAN WIN")
        break
    a = a+1
    death = round(SP*SDDP)
    healing = round(SP*SDHP)
    SP = round(SP+round(SP*RO) - death - healing-1)
    Population = round(Population - death)
    print("Day",a,"    ",death,"dead,",healing,"healed,",SP,"Current Patients,",Population,"is the current population")
    #print(SP)
    time.sleep(0.001)
    if a%7 == 0:
        ask = input("Change Virus Value?(Yes/No,need capitalization)")
        if ask == "Yes":
            SDDP = float(input('Please enter the new possibility of a patient dying in any day(in decimals, such as 0.01(1%):'))
            SDHP = float(input('Please enter the new possibility of a patient healing in any day(in decimals, such as 0.01(1%):'))
            RO = float(input('Please enter the new average number of people that can a patient can infect each day:'))
        else:
            print("OK")

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页