Hi. I am taking a python course(I am a complete beginner) and I am unable to solve one of the assigned exercises. Can someone help me understand how can I input the "t" into the code to get tN as output?
so far my code:
It has been discovered that a population of bacteria grows according to the following law: If there are nt bacteria
at time t then one hour later at time t + 1 there will be
nt+1 = (1 + *α[1- nt/K])*nt
where α is a positive number that controls the growth rate and K is a positive number that defines the capacity,
i.e., the maximum number of bacteria in the population.
Problem definition
Write a program that simulates the bacteria growth hour by hour and stops when the number of bacteria exceeds
some fixed number, N. Your program must return the time t at which the population first exceeds N. Even
though the actual number of bacteria is really a whole number (integer) your program must work with nt as a
decimal number (real), i.e., you should not round the numbers.
Solution template
def bacteriaGrowth(n0, alpha, K, N):
# Insert your code here
return tN
Input
n0 Initial number of bacteria (scalar)
alpha Growth rate (scalar)
K Capacity (scalar)
N Final population size (scalar, n0<N<K)
Output
tN Time t at which population size exceeds N (scalar)
Thank you for your help in advance....
so far my code:
import numpy as np import math def bacteriaGrowth(n0, alpha, K, N): a= alpha #" Growth rate" K= K #Capacity t= x if N[x+1] == (1 + a*[1- n0/K])*n0: N>n0 and N<K tN= x +1 return tNThe exercise description below....
It has been discovered that a population of bacteria grows according to the following law: If there are nt bacteria
at time t then one hour later at time t + 1 there will be
nt+1 = (1 + *α[1- nt/K])*nt
where α is a positive number that controls the growth rate and K is a positive number that defines the capacity,
i.e., the maximum number of bacteria in the population.
Problem definition
Write a program that simulates the bacteria growth hour by hour and stops when the number of bacteria exceeds
some fixed number, N. Your program must return the time t at which the population first exceeds N. Even
though the actual number of bacteria is really a whole number (integer) your program must work with nt as a
decimal number (real), i.e., you should not round the numbers.
Solution template
def bacteriaGrowth(n0, alpha, K, N):
# Insert your code here
return tN
Input
n0 Initial number of bacteria (scalar)
alpha Growth rate (scalar)
K Capacity (scalar)
N Final population size (scalar, n0<N<K)
Output
tN Time t at which population size exceeds N (scalar)
Thank you for your help in advance....