def infectrate(R0, weeks, incoming, isprint=True): frontier = incoming # frontier is new, infectious cases by week total = frontier # total infections for week in range(1, weeks+1): frontier = frontier * R0 total += round(frontier) # Python rounds .5 to nearest even if isprint: print("week,frontier,total", week, # round(frontier,2), round(total-incoming,2)) round(frontier), round(total-incoming)) return total-incoming