Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This program is about an imaginary animal called a jackalope. Each generation, the jackalope population increases by 1 0 % due to births and decreases
This program is about an imaginary animal called a jackalope. Each generation, the jackalope population increases by due to births and decreases by due to deaths. Both the number of jackalopes who die and who are born will be rounded to the nearest integer in each generation. So given the starting number of number of jackalopes calculate the final jackalopes population after given number of generations. See below for how to do this. So here is the algorithm for calculating the number of jackalopes:
repeat the following steps for the given number of generations:
calculate number of births: of population and round to nearest int
add those births to the population
calculate number of deaths: of population and round to nearest int
subtract those deaths from the population
Example : If you start with jackalopes, then more are born, increasing the number to of the die rounded to deaths decreasing the number to
Example : If you were to start with jackalopes, then would be born and of the would die, leaving us with jackalopes. The following generation, of the would produce births, and of would produce deaths, leaving us with after generations. Note that this isn't the same result as if we simply add each year. Also notice that you need to add births first before calculating deaths. # Below is the standard way we write complete applications in Python. Notice the major components. Please follow inline instructions. Please follow UMPIRE technique to solve this problem
# Your PLAN should go below
def calculatenumberofjackalopes: # You must pass the correct inputs as parameters. Make sure to collect those parameters in your main
Write your function Docstring here' # Function docstring says what it does.
# Make sure to return your result, don't print
# We use main program to use, test our solution. Sometimes we call it the client or the driver program.
def main:
# simply assign values for the input here.
# Make sure to use a while loop appropriately to call your function as long as user needs
# Code below simply runs the main
if namemain:
# call main here To help you figure out the logic of the forloop and calculations, I recommend you watch the video explaining a similar Interest Accumulation program in this module's Videos page.
You must use a loop to repeat the births and deaths for each generation. Do not use an exponential formula it will give you the wrong answers.
Write a single function to return the final number of jackalopes for a given start population and for number of given generations
Your program should allow the user to repeat the calculations as many times as they wish as above Use a while loop for this. That part is kind of similar to the zyBook program, : Bidding example" which is better shown in this repl version of the Bidding Example programLinks to an external site.. Use the main program for this part of the program and call your function as long as user want to run our function for more trials.
To round a floatingpoint variable to the nearest integer value, use the round function. For example, to make births equal of population, rounded to the nearest integer:
births roundpopulation
You must test and demonstrate your program with the last test cases above and others if you wish
You should get the exact same answers as shown above. Most slight differences are caused by doing the calculations in a slightly different orderway For example, population including new births must be used to calculate deaths.
Make sure to put a comment at the top of your program with your name, the name of this assignment and class CS Jackalope Populations and a brief description of what the program does.
Submit the Python source code and sample output with the above numbers, showing how your program worked with different inputs.
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