Question

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) x (1A- Bx 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.PYHTON

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code Screenshots:

# Read and store the # initial population # size of the preys. num_prey = int(input () ) # Read and store the # initial popul

Sample Input:

1000 20 0.1 0.01 0.01 0.00009 30

Sample Output:

| 23 18

Code to Copy:

# Read and store the

# initial population

# size of the preys.

num_prey = int(input())

# Read and store the

# initial population

# size of the predators.

num_pred = int(input())

# Read and store the

# values for A, B, C,

# D, and t.

A = float(input())

B = float(input())

C = float(input())

D = float(input())

t = int(input())

# Run the loop

# to perform the

# calculations, t times.

for i in range(t):

    # Get the current population

    # sizes using the previous

    # population sizes.

    curr_prey = num_prey * (1 + A - B * num_pred)

    curr_pred = num_pred * (1 - C + D * num_prey)

    

    # Update the

    # population sizes.

    num_prey = int(curr_prey)

    num_pred = int(curr_pred)

# Print the final

# population sizes.

print(num_prey, num_pred)

Add a comment
Know the answer?
Add Answer to:
PYHTON 5.27 LAB: Predator-Prey Simulation In a predator-prey simulation, you compute the populations of predators and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • USING PYTHON Thank you. For this lab, you will write an eco-system simulation for two species:...

    USING PYTHON Thank you. For this lab, you will write an eco-system simulation for two species: predator and prey. The prey is the primary food source for the predator. During each round of the simulation, the number of prey will increase or decrease (due to predation, other deaths, and births), and the number of predators will increase or decrease (due to births and deaths). Overview For this lab, we will write an eco-system simulation for two species: predator and prey....

  • Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in...

    Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in C++ Implementing classes Using vectors Using command line arguments Modifying previously written code Tasks For this project, you will implement a simulation for predicting the future populations for a group of animals that we’ll call prey and their predators. Given the rate at which prey births exceed natural deaths, the rate of predation, the rate at which predator deaths exceeds births without a food...

  • Populations grow when the number of births in a population is greater than the number of...

    Populations grow when the number of births in a population is greater than the number of deaths in the same population and there is no net movement of individuals into or out of the population. This is to say that all else being equal, populations grow when the birth rate exceeds the death rate and shrink when death rates exceed birth rates. When the number of births is equal to the number of deaths in a population, and again, there...

  • 1) If you examined predator-prey relationships within an ecosystem and noticed that the removal of predators...

    1) If you examined predator-prey relationships within an ecosystem and noticed that the removal of predators also resulted in the die-off of herbivores, what would you suspect occurred? a) Removal of predators would directly lower the number of herbivores. b) The lack of predators could mean that too much primary production occurred. c) Herbivores from another region may have entered the ecosystem and consumed the primary producers, causing death of the original herbivores species. d) Overeating by herbivores could have...

  • In C++ Transient Population Populations are effected by the birth and death rate, as well as...

    In C++ Transient Population Populations are effected by the birth and death rate, as well as the number of people who move in and out each year. The birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. Write a program that displays the size of a population for any number of years. The program should ask for the following data: The starting size...

  • All of the following questions are in relation to the following journal article which is available...

    All of the following questions are in relation to the following journal article which is available on Moodle: Parr CL, Magnus MC, Karlstad O, Holvik K, Lund-Blix NA, Jaugen M, et al. Vitamin A and D intake in pregnancy, infant supplementation and asthma development: the Norwegian Mother and Child Cohort. Am J Clin Nutr 2018:107:789-798 QUESTIONS: 1. State one hypothesis the author's proposed in the manuscript. 2. There is previous research that shows that adequate Vitamin A intake is required...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT