Question
(Please show your code screen, the pseudo code doesn't always help and I run into errors.) Language is Python. Problem: Suppose that a scientist is
(Please show your code screen, the pseudo code doesn't always help and I run into errors.) Language is Python.
Problem:
Suppose that a scientist is doing some important research work that requires her to use rabbits in her experiments. She always starts out with one adult male rabbit and one adult female rabbit. At the end of each month, a pair of adult rabbits produces one pair of offspring, a male and a female. These new offspring will take one month to mature and become adults.
To illustrate this, consider the first two months. At the beginning of month one, the scientist just has the original one pair of adult rabbits. A table for month one will look something like:
Month | Adult | Babies | Total |
1 | 1 | 0 | 1 |
At the end of month one this pair of adults produces one pair of offspring. Thus, at the beginning of month two the table will look like this:
Month | Adult | Babies | Total |
1 | 1 | 0 | 1 |
2 | 1 | 1 | 2 |
At the end of month two the adults have another pair of baby rabbits. The first pair of babies, born at the end of last month are not old enough to have babies yet, but we will categorize them as adults. So, at the beginning of month three the table looks like this:
Month | Adult | Babies | Total |
1 | 1 | 0 | 1 |
2 | 1 | 1 | 2 |
3 | 2 | 1 | 3 |
The scientist has 500 cages in which to hold her rabbits. Each cage holds one pair of rabbits. Assuming that no rabbits ever die, when will she run out of cages?
Your program must do the following:
- Open a text file rabbits.csv for writing. Where it says "print" below, it means "write to the output file". Remember to close the file when done.
- Print a table that contains the following information for each month.
- The number of months that have passed.
- The number adult rabbit pairs (those over 1 month old).
- The number of baby rabbits pairs produced this month.
- The total number of rabbit pairs in the lab.
- Calculate how many months it will take until the number of rabbits exceeds the number of available cages.
- Stop printing when you run out of cages.
- Print a message giving how many months it will take to run out of cages
Output file should look like the following. Comments in the file begin with '#', and must appear as shown too:
# Table of rabbit pairs Month, Adults, Babies, Total 1, 1, 0, 1 2, 1, 1, 2 3, 2, 1, 3 4, 3, 2, 5 5, 5, 3, 8 6, 8, 5, 13 7, 13, 8, 21 8, 21, 13, 34 9, 34, 21, 55 10, 55, 34, 89 11, 89, 55, 144 12, 144, 89, 233 13, 233, 144, 377 14, 377, 233, 610 # Cages will run out in month 14
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