Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Programming, previous code for parts A and B below, looking for answers on part C: import random def six_tails () : counter = 0

Python Programming, previous code for parts A and B below, looking for answers on part C:

import randomdef six_tails(): counter = 0 number_of_tries = 0 while counter != 6: number_of_tries = number_of_tries + 1 toss = random.randint(0, 1) if toss == 0: counter = counter + 1 else: counter = 0 print(number_of_tries)six_tails()def average_six(n): sum_tries = 0 for i in range(n): sum_tries += six_tails() average_tries = sum_tries / n return average_triesprint(average_six(100))print(average_six(1000))print(average_six(10000))

Part C problem and examples below:

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Problem C. (10 points) There's Always a Bigger Fish One simple model of predator-prey populations is the . This model has three basic tenets, which have at least some basis in reality: a Without the inuence of predators, the prey's population experiences exponential growth (we assume here that the prey always have enough food). Without the inuence of prey, the predator's population experiences exponential decay (we assume here that the prey is the predator's primary food source). Interactions between predators and prey cause the prey's population to go down (because they are eaten), and the predator's 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, we'll be using a similar model to simulate the populations of three types of sh living in an isolated lake. We'll call these bigsh, middlesh, and smallsh. The bigsh primarily consume middlesh, the middlefish primarily consume smallfish, and the smallsh do not. require sustenance because they are magic. Let small be the number of smallsh, medium be the number of middlesh, and big be the number of bigsh in the lake during some week. The next week, the new population for each sh is given by the following equations: new_small = int(1.1*small 0.0002*sma11*middle) new_middle = int(0.95*middle + 0.6661*small*middle - 0.06625*middle*big) new_big = int(0.9*big + 9.9802*middle*big) Complete the function called popu lat ion (sma l 1 , midd le , big), which takes three integers as arguments, representing the initial numbers of smallfish, middlesh, and bigsh in the lake, respectively. The function should simulate the change in population each week using the equations above, and print out the populations. The function should return the number of weeks it takes for one of the populations to be essentially wiped out (less than 10 members), or 30 in the case that all three populations are still greater than or equal to 10 after 30 weeks. Hints: 0 Make sure you update the small, middle, and big variables to their new values each week (but don't do so until AFTER you have computed the new values for all three, or the equations will yield the wrong values). Constraints: 0 Do not use the input() function. 0 Remember, using break is considered bad style. Figure out how to write your loop condition in a way that b r'ea k is not required. Your submission should have no code outside of function denitions aside from import statements. Examples (text in bold is returned, everything else is printed): >>> population(1@6J 25, 76) week 1 - Small: 189 Middle: 23 Big: 63 week - Small: 119 Middle: 21 Big: 56 week - Small: 139 Middle: 19 Big: 56 week - Small: 142 Middle: 18 Big: 45 week Small: 155 Middle: 17 Big: 48 week Small: 169 Middle: 16 Big: 36 week Small: 185 Middle: 15 Big: 32 week Small: 262 Middle: 14 Big: 28 week Small: 221 Middle: 13 Big: 25 week Small: 242 Middle: 12 week Small: 265 Middle: 11 week Small: 290 Middle: 10 week Small: 318 Middle: 9 13 \f> >> population(800, 600, 1000) Week 1 - Small: 784 Middle: 468 Big: 1020 Week 2 - Small: 789 Middle: 361 Big: 1013 Week 3 - Small: 810 Middle: 280 Big: 984 Week 4 - Small: 845 Middle: 219 Big: 940 Week 5 - Small: 892 Middle: 175 Big: 887 Week 6 - Small: 949 Middle: 143 Big: 829 Week 7 - Small: 1016 Middle: 119 Big: 769 Week 8 - Small: 1093 Middle: 102 Big: 710 Week 9 - Small: 1180 Middle: 89 Big: 653 Week 10 - Small: 1276 Middle: 80 Big: 599 Week 11 - Small: 1383 Middle: 74 Big: 548 Week 12 - Small: 1500 Middle: 70 Big: 501 Week 13 - Small: 1629 Middle: 68 Big: 457 Week 14 - Small: 1769 Middle: 67 Big: 417 Week 15 - Small: 1922 Middle: 68 Big: 380 Week 16 - Small: 2088 Middle: 71 Big: 347 Week 17 - Small: 2267 Middle: 76 Big: 317 Week 18 - Small: 2459 Middle: 83 Big: 290 Week 19 - Small: 2664 Middle: 93 Big: 265 Week 20 - Small: 2880 Middle: 106 Big: 243 Week 21 - Small: 3106 Middle: 124 Big: 223 Week 22 - Small: 3339 Middle: 149 Big: 206 Week 23 - Small: 3573 Middle: 183 Big: 191 Week 24 - Small: 3799 Middle: 230 Big: 178 Week 25 - Small: 4004 Middle: 295 Big: 168 Week 26 - Small: 4168 Middle: 385 Big: 161 Week 27 - Small: 4263 Middle: 510 Big: 157 Week 28 - Small: 4254 Middle: 681 Big: 157 Week 29 - Small: 4100 Middle: 909 Big: 162 Week 30 - Small: 3764 Middle: 1199 Big: 175 30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Best practice Electrolux: a portfolio company

Answered: 1 week ago