Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.10 KB | None | 0 0
  1. import math
  2.  
  3. def main():
  4.         space, mylist = calculate()
  5.         graphics(space,mylist)
  6.        
  7.  
  8.  
  9. def calculate():
  10.         numberOfDays = int(input("How many whole days have passed? "))
  11.         infectionRate = (1 + float(input("What is the infection rate? ")))
  12.         recoveryRate = int(input("After how many days do patients come out of ICU? "))
  13.         space = len(str(math.ceil(10*(infectionRate)**(numberOfDays-1))))
  14.         mylist = []
  15.         newlist = []
  16.         for i in range (1, numberOfDays+1):
  17.                 roundedInfected = (math.ceil(10*infectionRate**(i-1)))
  18.                 subtractedInfected = math.ceil(10*infectionRate**(i-recoveryRate-1))
  19.                 ICUinfected = (0.1*roundedInfected)-subtractedInfected
  20.                 if ICUinfected > 8000:
  21.                         YesNoInfected ="No"
  22.                         newlist.append([YesNoInfected])
  23.                 else:
  24.                         YesNoInfected = "Yes"
  25.                 mylist.extend([[str(i), roundedInfected, YesNoInfected]])
  26.         InfectedDays = int(numberOfDays) - int(len(newlist))
  27.        
  28.         if len(newlist)> 0:
  29.                 print(space)
  30.                 print("\nAfter", InfectedDays, "days, the NHS can't cope with this number of infections.")
  31.  
  32.                
  33.         return space, mylist
  34.  
  35. def graphics(space, mylist):
  36.         if space < 25:
  37.                 print("\n| Number of Days |", "Number of people infected","|", "Can the NHS handle this number of infections? |")
  38.                 for item in mylist:
  39.                         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]))), "|")
  40.         else:
  41.                 print("\n| Number of Days |", "Number of people infected ", (" ")*(space-22), "|", "Can the NHS handle this number of infections? |")
  42.                 for item in mylist:
  43.                         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]))), "|")
  44. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement