Question
Solve in Python Language Please One simple model of predator-prey populations is the LotkaVolterra equations. This model has three basic tenets, which have at least
Solve in Python Language Please
One simple model of predator-prey populations is the LotkaVolterra equations. This model has three basic tenets, which have at least some basis in reality:
-
Without the influence of predators, the preys population experiences exponential growth (we assume here that the prey always have enough food).
-
Without the influence of prey, the predators population experiences exponential decay (we assume here that the prey is the predators primary food source).
-
Interactions between predators and prey cause the preys population to go down (because they are eaten), and the predators to go up (because they are able to feed themselves and their young). Interactions are proportional to both the number of prey in the area and the number of predators.
In this problem, well be using a similar model to simulate the populations of three types of fish living in an isolated lake. Well call these bigfish, middlefish, and smallfish. The bigfish primarily consume middlefish, the middlefish primarily consume smallfish, and the smallfish do not require sustenance because they are magic.
Each week, we simulate the population change with the following sequence of calculations, executed in order:
-
The number of smallfish is multiplied by 1.1 (rounded to the nearest integer)
-
The number of middlefish is multiplied by 0.95 (rounded to the nearest integer)
-
The number of bigfish is multiplied by 0.9 (rounded to the nearest integer)
-
The number of smallfish that are eaten by middlefish during the week is calculated as
0.0001*(# of smallfish)*(# of middlefish), rounded to the nearest integer
Subtract this number from the smallfish population, and then multiply it by two and add that number to the middlefish population (each smallfish feeds two new middlefish)
-
The number of middlefish that are eaten by bigfish during the week is calculated as
0.0002*(# of middlefish)*(# of bigfish), rounded to the nearest integer
Subtract this number from the middlefish population, and then add it to the bigfish population (each middlefish feeds one new bigfish)
For example, suppose that we started with 842 smallfish, 617 middlefish, 402 bigfish. Here is what each step would look like for the first week:
-
We start with 842 smallfish, 842*1.1 = 926.2. Round that to 926 smallfish
-
We start with 617 middlefish, 600*0.95 = 586.15. Round that to 586 middlefish
-
We start with 402 bigfish, 402*0.9 = 361.8. Round that to 362 bigfish.
-
The number of smallfish eaten is 0.0001*926*586 = 54.2636. Round that to 54. So we subtract 54 smallfish (926 - 54 = 872 smallfish), and add 54*2 = 108 middlefish (586+108 = 694 middlefish)
-
The number of middlefish eaten is 0.0002*694*362 = 50.2456. Round that to 50. So we subtract 50 middlefish (694 - 50 = 644 middlefish), and add 50 bigfish (362+50 = 412 bigfish)
Meaning at the end of week 1, we have 872 smallfish, 644 middlefish, and 412 bigfish.
Complete the function called population(small, middle, big), which takes three integers as arguments, representing the initial numbers of smallfish, middlefish, and bigfish in the lake, respectively. The function should simulate the change in population each week for three weeks using the equations above, and print out the populations. The function should return the total number of fish at the end of the third week (that is, small + middle + big).
For functions with multiple parameters such as this one, each parameter and its short description should be listed on a separate line:
Parameter(s):
param1: Description of param1
param2: Description of param2
Hints:
-
To round values to the nearest integer, use the round() built-in function. Make sure you round each time the instructions say to do so.
-
If you want to look ahead in zyBooks to how loops work, you can avoid having to copy-paste the code for each week 3 times. But thats not required.
-
If youre getting the wrong answers, then calculate what the populations should be after each of the 5 steps using a calculator (or just use the example above), then print out the values of the variables after each step to see where you start getting the wrong result.
Examples (text in italics is printed, text in bold is returned)
>>> population(842, 617, 402)
Week 1 - Small: 872 , Middle: 644 , Big: 412
Week 2 - Small: 900 , Middle: 676 , Big: 425
Week 3 - Small: 926 , Middle: 711 , Big: 441
2078
>>> population(1000, 1000, 1000)
Week 1 - Small: 996 , Middle: 950 , Big: 1108
Week 2 - Small: 997 , Middle: 881 , Big: 1216
Week 3 - Small: 1005 , Middle: 798 , Big: 1317
3120
>>> population(8423, 828, 321)
Week 1 - Small: 8536 , Middle: 2115 , Big: 419
Week 2 - Small: 7504 , Middle: 5345 , Big: 813
Week 3 - Small: 4063 , Middle: 11489 , Big: 2703
18255
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started