Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def main():
- space, mylist = calculate()
- graphics(space,mylist)
- def calculate():
- numberOfDays = int(input("How many whole days have passed? "))
- infectionRate = (1 + float(input("What is the infection rate? ")))
- recoveryRate = int(input("After how many days do patients come out of ICU? "))
- space = len(str(math.ceil(10*(infectionRate)**(numberOfDays-1))))
- mylist = []
- newlist = []
- for i in range (1, numberOfDays+1):
- roundedInfected = (math.ceil(10*infectionRate**(i-1)))
- subtractedInfected = math.ceil(10*infectionRate**(i-recoveryRate-1))
- ICUinfected = (0.1*roundedInfected)-subtractedInfected
- if ICUinfected > 8000:
- YesNoInfected ="No"
- newlist.append([YesNoInfected])
- else:
- YesNoInfected = "Yes"
- mylist.extend([[str(i), roundedInfected, YesNoInfected]])
- InfectedDays = int(numberOfDays) - int(len(newlist))
- if len(newlist)> 0:
- print(space)
- print("\nAfter", InfectedDays, "days, the NHS can't cope with this number of infections.")
- return space, mylist
- def graphics(space, mylist):
- if space < 25:
- print("\n| Number of Days |", "Number of people infected","|", "Can the NHS handle this number of infections? |")
- for item in mylist:
- print("|", str(item[0]), (" ")*(13-len(str((item[0])))), "|", str(item[1]), (" ")*(24-len(str(item[1]))), "|",str(item[2]), (" ")*(44 - len(str(item[2]))), "|")
- else:
- print("\n| Number of Days |", "Number of people infected ", (" ")*(space-22), "|", "Can the NHS handle this number of infections? |")
- for item in mylist:
- print("|", str(item[0]), (" ")*(13-len(str(item[0]))), "|", str(item[1]), (" ")*(4+(space-len(str(item[1])))), "|", str(item[2]), (" ")*(44 - len(str(item[2]))), "|")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement