##Example 1 import math bacteria = int(input("How many bacteria are at the start? ")) minutes = int(input("How many minutes are in the double time? ")) hours = float(input("How many hours would you like to wait? ")) time = hours*60 difference = minutes-time while difference<=(.5*minutes): bacteria = bacteria*2 time=time -minutes difference = minutes-time print("After",hours,"hours there would be",bacteria,"bacteria.") ######################### ##Example 2 bacteria = int(input("How many bacteria are at the start? ")) double = int(input("How many minutes are in the double time? ")) hours = float(input("How many hours would you like to wait? ")) hours = hours*60 interval = int(round(hours/double,0)) while interval!=0: bacteria = bacteria * 2 interval = interval - 1 hours=hours/60 print("After "+str(hours)+" hours there would be "+str(bacteria)+" bacteria.") ######################### ##Example 3 start= int(input("How many bacteria are at the start?")) double= int(input("How many minutes are in the double time?")) hours= float(input("How many hours would you like to wait?")) growth= (hours*60)/double growth= round(growth) for x in range(growth): start= start*2 print("After", hours, "hours there would be", start, "bacteria.") ######################### ##Example 4 start=int(input("How many bacteria are at the start? ")) dt=int(input("How many minutes are in the double time? ")) hrs=float(input("How many hours would you like to wait? ")) minsdt=hrs*60 remainder=minsdt%dt total=start if remainder%dt<10: cycle=int((minsdt-remainder)/dt) else: cycle=int((minsdt+(dt-remainder))/dt) growth=start*2 for bacteria in range(cycle): growth=start*2**bacteria total=total+growth print("After",hrs,"hours there would be",total,"bacteria.")