1. Engineering
  2. Computer Science
  3. python...

Question: python...

Question details

5.27 LAB: Predator-Prey Simulation In a predator-prey simulation, you compute the populations of predators and prey using the following equations prey(t + 1)-prey(t) × (1 + A-B x pred(t)) pred(t + 1) pred(t) x (1-C+ D x prey(t)) Here, A is the rate at which prey birth exceeds natural death, B is the rate of predation, C is the rate at which predator deaths exceed births without food, and D represents predator increase in the presence of food. The units of time t are expressed in years Write a program that prompts the user for the initial population sizes, these rates, and the number of years. Then print the populations for the given number of years after your simulation has completed Hint: This can be accomplished in about 15 lines of code LAB ACTIVITY 5.27.1: LAB: Predator-Prey Simulation 0 10 main.py Load default template... 1 # 0btain the input from the user 2 int(input()) # Initial number of prey # Initial number of predators # Rate of natural prey growth # Rate of predation # Rate of predator decline w/o food # Rate of predator growth w/ food # Periods to simulate num-prey 3 num_pred int(inputO) 4 = A = float(input()) 5 B float(inputO) 6 C float(inputO) 7 D= float(input()) 8 periodsint(inputO 10 11 FIXME: Write the code to implement the predator-prey simulation. Update the num_prey and num_pred variables 12 during each iteration. The values may become non-integer; so use intO to typecast the values back to integer form 13 14 15 16 Print the final values of the prey and the predators. If variables 17 num_prey and num_pred contain the final values, then print(num_prey, num_pred) 18: Compare output Output differs. See highlights below. 1000 20 0.1 Input 0.01 0.01 0.00009 30 Your output 9002 1 Expected output 23python

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution