Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 4 : Hailstone Sequences In mathematics, a hailstone sequence is a sequence creates as follows: Select a starting value for the sequence. If a
Problem : Hailstone Sequences
In mathematics, a hailstone sequence is a sequence creates as follows:
Select a starting value for the sequence.
If a particular term in the sequence is equal to then the next term will be equal to if is even, and will be
equal to if is odd.
The sequence continues until reaching a term that is equal to
For example, the hailstone sequence beginning with is:
It is widely believed that any starting value will result in a sequence that eventually reaches but this has not been proven
to be true.
Use while loops to calculate the hailstone sequences beginning with and storing the sequences in order in
lists named hs hs and hs This will require three separate but nearly identical loops. The elements stored in
the lists should be integers as opposed to floats Print the contents of the three lists.
Problem : PredatorPrey Model
Assume that a certain ecosystem contains both rabbits and wolves. The size of the rabbit population and the size of the
wolf population both fluctuate, and have an effect on each other. Suppose that the current sizes of the populations can be
used to determine the sizes of the populations one year from now according to the following population model:
Let be the current size of the rabbit population.
Let be the current size of the wolf population.
Let be the size of the rabbit population one year from now.
Let be the size of the wolf population one year from now
The population sizes one year from now are determine by the following equations:
Suppose that the current rabbit population is and the current wolf population is Under these circumstances, the
populations will fluctuate for several years, but the rabbit population will eventually die out completely.
In this problem, you will be asked to calculate the size of each population at the end of each year until the the rabbit
population dies out.
Perform the following steps in a single code cell:
Create variables rpop and wpop to store the current rabbit and wolf populations which are provided above
Print the first three rows of the table shown below the column headers, the dashed line, and the year info
Use a loop to determine the new populations at the end of each new year. Each time the loop executes,
perform the steps below. The loop should continue to run for as long as both populations are greater than zero.
Store the current population values in temporary variables named rpopprev and wpopprev.
Use the formulas provided to calculate the new population sizes. Round the results to the nearest
integer, and store these values in rpop and wpop as integers
If any population end up being negative, it should be changed to
Print a new line of the table below with updated values.
Year rpop wpop
No lists should be created for this problem, and only one loop should be used.
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