Population dynamics 2

Conditional Statements

During the previous assignment, we calculated how many elephants would live in Kruger National Park after 20 years. In this assignment, we will continue working with the script we wrote and use the same data.

It is important for researchers to closely monitor the evolution of the population. To facilitate this, the previous script will be modified to include an automatic alert if the population exceeds or falls below a certain critical value.

The growth rate of a population can be positive, negative, or zero. A positive growth rate (r>0) indicates that the population is increasing in size. This can result from factors such as births, immigration, or favorable environmental conditions. A negative growth rate (r<0) indicates that the population is decreasing in size. This may be due to factors such as deaths, emigration, or unfavorable environmental conditions. A growth rate of zero (r=0) indicates that the population size remains constant, which can occur when births and deaths, as well as immigration and emigration, balance each other out.

Assignments

Write a Python script that includes the following functionalities.

  1. Ask the user to input the following data:
  1. Determine the change in population size based on the entered growth rate. Use an if-elif-else structure to check whether the population is increasing, decreasing, remaining constant, or if an invalid value was provided.
  2. Print the result on the screen with an appropriate message: “The population is increasing,” “The population is decreasing,” “The population remains constant,” or “An invalid value was provided”
  3. When the population becomes too large, it will exceed the carrying capacity of the area. Check if the number of individuals exceeds this carrying capacity at N_t. Print: “The carrying capacity is (not) exceeded after x years”

as a reminder:

\[N_t=N_0* e^{r*t}\]

Example

Input:

>>>Enter a growth rate: 0.03946
>>>Enter the initial size of the population: 7806
>>>Enter the time (in years) for which you want to determine the number of individuals: 20
>>>Enter the carrying capacity: 50000

Output:

The population is increasing.
The carrying capacity is not exceeded.
20