Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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:

  1. 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.
  2. 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.
  3. Calculate how many months it will take until the number of rabbits exceeds the number of available cages.
  4. Stop printing when you run out of cages.
  5. 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

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

=+4 How did it affect HR?

Answered: 1 week ago