Population dynamics 3.2

Control loops

Assignment

Write a Python script that includes the following functionalities.

  1. Ask the user to input the following values:
  1. Implement a while loop to calculate the population size for the first 5 years and print it in the following format:

    Time point 1 – population size: 46384

    Use the following formula to calculate the population size:

    \[𝑁𝑡=\frac{𝐾}{1+(\frac{𝐾}{𝑁_0}−1)∗𝑒{−𝑟∗𝑡}}\]
  2. Implement a while loop to calculate the population size for each time step. Ensure that the time values increase from 1 to t in increments of 5 years, where t is the time specified by the user. Calculate at which time point (in years) 99% of the carrying capacity is exceeded. If this occurs, the loop should stop, and the message should appear:

    99% van de draagkracht werd bereikt
    Aantal jaren 160 - populatiegrootte: 49515

Example

Input:

    >>>Enter the growth rate: 0.3
    >>>Enter the initial size of the population: 100
    >>>Enter the time (in years) for which you want to determine the number of individuals: 40
    >>>Enter the carrying capacity: 100

Output:

    Time point 1 - population size: 64
    Time point 2 - population size: 76
    Time point 3 - population size: 85
    Time point 4 - population size: 91
    Time point 5 - population size: 95
    99% of the carrying capacity was reached
    Number of years 10 - population size: 99