Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 3: Population Change with Bears (20 pts) You are going to write a program to coenpute a type of population balaace problea similar to

image text in transcribed
Part 3: Population Change with Bears (20 pts) You are going to write a program to coenpute a type of population balaace problea similar to the bannies and fooes you compated in Lab 3. This problem will have bears, berry fiekls, and tourists. We will just use the word betries to mean the area of the bey fields. We will count the wumber of bears and tourists, as well. Bears need a lot of berries to survive and get ready for winter. So the area of berry Sekls is a very important part for their popalation. Berry Eekis in general spread over time, but if they are trampled too heavily by bears, then they may stop growing and may reduce ine. Tourists are the worst enemy of bears, often habituating them to hmans and causing aggressive behavior. Sadly this can lead to bears being killed to avoid risk to human life Here is how the population of each group is linked to one abother fron one year to the next Suppose the variable bears stores the nuamber of bears in a given year and berries stores the area of the berry fields. The nanber of tourists in a siven year is determined as folows. If there are less than 4 or more than 15 bears, there are no tourists. It is either not interesting enough or too dangesous or them In other cases, there are 10,000 tourists for each bear up to and inchading 10 and then 20000 tourists for each additional bear, It is a great idea to write a function for computing tourists and test it separately The number of bears and berries in the next year is determined by the following formalas given the popiulation of bears, berries, and tourists in the given year bears next berries/(S0.(bears+1))bears.0.60 (math.log(1+tourists,10)-0.1) berries aext (berries 1.5)-(bears+) (berries/14) nath.log(1 tourists, 10)+0.05) Remember none of these values can end up being negative. Negative ralues should be elipped to ero Also, bears and tourists are integers. The log function is in the nath module. You ast write a fanction that tales as input the namber of bears, berries, and tourists in a given year and returas the next year's bears population and berry field area as a tupk find next (5, 100040000) (5, 1071.1984678861438) Then write the main program that reads two values, the curent popalation of bears, and the area of berry fields. our program then finds and prists the populstion of all three groups (bears, berries, and tourists) for the first year and another 9 years (10 years total). You nst use a loop to do this. The output is Sormatted such that all valas ase printed in colmas and ae aligaed to the left within cach couin. The width od each column is exactly 10 charactees (padded with spaces, if becessary).All Boating point values need to be printed with exactly ose decinaal place Ouee completed, your program should output: the smallest and largest values of the population of bears, berries, and tourists reached in your computation. These valas should be oatput using the same formatting rules as for the population values for each of the years. An example of the program run (how it will look when you nun it using Wing IDE 101) is provided in file hu3 part3 output 01.txt (can be found inside the hu03 files.zip fi) Note that the umber of bears may go down to zero and then come back up. Why? Bears fron seighboring areas can move in. The min and max vaaes for each of hears, berries, and tourists may coane from different years, Part 3: Population Change with Bears (20 pts) You are going to write a program to coenpute a type of population balaace problea similar to the bannies and fooes you compated in Lab 3. This problem will have bears, berry fiekls, and tourists. We will just use the word betries to mean the area of the bey fields. We will count the wumber of bears and tourists, as well. Bears need a lot of berries to survive and get ready for winter. So the area of berry Sekls is a very important part for their popalation. Berry Eekis in general spread over time, but if they are trampled too heavily by bears, then they may stop growing and may reduce ine. Tourists are the worst enemy of bears, often habituating them to hmans and causing aggressive behavior. Sadly this can lead to bears being killed to avoid risk to human life Here is how the population of each group is linked to one abother fron one year to the next Suppose the variable bears stores the nuamber of bears in a given year and berries stores the area of the berry fields. The nanber of tourists in a siven year is determined as folows. If there are less than 4 or more than 15 bears, there are no tourists. It is either not interesting enough or too dangesous or them In other cases, there are 10,000 tourists for each bear up to and inchading 10 and then 20000 tourists for each additional bear, It is a great idea to write a function for computing tourists and test it separately The number of bears and berries in the next year is determined by the following formalas given the popiulation of bears, berries, and tourists in the given year bears next berries/(S0.(bears+1))bears.0.60 (math.log(1+tourists,10)-0.1) berries aext (berries 1.5)-(bears+) (berries/14) nath.log(1 tourists, 10)+0.05) Remember none of these values can end up being negative. Negative ralues should be elipped to ero Also, bears and tourists are integers. The log function is in the nath module. You ast write a fanction that tales as input the namber of bears, berries, and tourists in a given year and returas the next year's bears population and berry field area as a tupk find next (5, 100040000) (5, 1071.1984678861438) Then write the main program that reads two values, the curent popalation of bears, and the area of berry fields. our program then finds and prists the populstion of all three groups (bears, berries, and tourists) for the first year and another 9 years (10 years total). You nst use a loop to do this. The output is Sormatted such that all valas ase printed in colmas and ae aligaed to the left within cach couin. The width od each column is exactly 10 charactees (padded with spaces, if becessary).All Boating point values need to be printed with exactly ose decinaal place Ouee completed, your program should output: the smallest and largest values of the population of bears, berries, and tourists reached in your computation. These valas should be oatput using the same formatting rules as for the population values for each of the years. An example of the program run (how it will look when you nun it using Wing IDE 101) is provided in file hu3 part3 output 01.txt (can be found inside the hu03 files.zip fi) Note that the umber of bears may go down to zero and then come back up. Why? Bears fron seighboring areas can move in. The min and max vaaes for each of hears, berries, and tourists may coane from different years

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

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

1. What are your creative strengths?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago