Answered step by step
Verified Expert Solution
Link Copied!

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 10% due to births and decreases by 2% 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 4 steps for the given number of generations:
calculate number of births: 10% of population (0.1), and round to nearest int
add those births to the population
calculate number of deaths: 2% of population (0.02), and round to nearest int
subtract those deaths from the population
Example 1: If you start with 200 jackalopes, then 10% more are born, increasing the number to 220.2% of the 220 die (rounded to 4 deaths), decreasing the number to 216.
Example 2: If you were to start with 132 jackalopes, then 13 would be born and of the 145,3 would die, leaving us with 142 jackalopes. The following generation, 10% of the 142 would produce 14 births, and 2% of 156 would produce 3 deaths, leaving us with 153 after 2 generations. Note that this isn't the same result as if we simply add 8% 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 calculate_number_of_jackalopes(): # 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 __name__=="__main__":
# call main() here To help you figure out the logic of the for-loop 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, "12.3.2: 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 floating-point variable to the nearest integer value, use the round function. For example, to make births equal 10% of population, rounded to the nearest integer:
births = round(population *0.1)
You must test and demonstrate your program with the last 3 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 order/way. 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 10 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

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

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

How is communication defi ned?

Answered: 1 week ago

Question

What are the benefi ts of studying communication?

Answered: 1 week ago