Answered step by step
Verified Expert Solution
Link Copied!

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 4: 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 /2 if is even, and will be
equal to 3+1 if is odd.
The sequence continues until reaching a term that is equal to 1.
For example, the hailstone sequence beginning with 12 is: 12,6,3,10,5,16,8,4,2,1
It is widely believed that any starting value will result in a sequence that eventually reaches 1, but this has not been proven
to be true.
Use while loops to calculate the hailstone sequences beginning with 15,17, and 22, storing the sequences (in order) in
lists named hs15, hs17, and hs22. 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 5: Predator/Prey 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 A be the current size of the rabbit population.
Let B be the current size of the wolf population.
Let C be the size of the rabbit population one year from now.
Let D be the size of the wolf population one year from now
The population sizes one year from now are determine by the following equations:
C=1.5 A 0.002 A B
D =0.8 B +0.0003 A B
Suppose that the current rabbit population is 1000 and the current wolf population is 200. 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:
1. Create variables r_pop and w_pop to store the current rabbit and wolf populations (which are provided above).
2. Print the first three rows of the table shown below (the column headers, the dashed line, and the year 0 info).
3. 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 r_pop_prev and w_pop_prev.
Use the formulas provided to calculate the new population sizes. Round the results to the nearest
integer, and store these values in r_pop and w_pop (as integers).
If any population end up being negative, it should be changed to 0.
Print a new line of the table below with updated values.
Year r_pop w_pop
-----------------------
01000200
11100220
21166249
.........
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

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_2

Step: 3

blur-text-image_3

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

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions

Question

2. What are the different types of networks?

Answered: 1 week ago