Question: EASY Language: Python Program used: PyCharm Interpreter: 3.6.1 at ~/anaconda/bin/python Question 2 (9 points): Purpose: To practice using various kinds of loops (and do some

EASY Language: Python

Program used: PyCharm

Interpreter: 3.6.1 at ~/anaconda/bin/pythonEASY Language: Python Program used: PyCharm Interpreter: 3.6.1 at ~/anaconda/bin/python Question 2(9 points): Purpose: To practice using various kinds of loops (and do

Question 2 (9 points): Purpose: To practice using various kinds of loops (and do some science at the same time!) Degree of Difficulty: The coding here is Easy. But read the description carefully! When scientists, economists, or business analysts seek to understand a complex dynamic process, they might develop a simplified mathematical model which they can use to understand the complex system. In this question, we'll draw on a simple model from biology, but from this example, you can imagine how to do similar studies in any field. The model The population of bacteria in a test tube (or zombies on an island) increases and decreases over time depending on how large the current population is, and how quickly the bacteria reproduce. We'll model the total population using a floating point number in the range from O (meaning extinct) to 1 (meaning the maximum population that can be sustained). We will model time using an integer counter that starts at O and increases by 1 up to some preset limit given by the user. In this model, time is abstract: we are simply counting time steps, assuming that each step is the same duration, but without committing to seconds, or hours, or years. Suppose that the population at time t is p. Our simple model predicts that the population one time step later, ie, at t +1, is (rxpx (1-p)), where r is a real number in the model that represents how the population of bacteria (or zombies) changes in a single time-step. The value r does not change Sample Run: Console output Sample input and output (input typed by the user is shown in green text: How many time steps to simulate? 5 What 's the rate of change? 2.7 What 's the starting population? 0.3 Time Population 0 0.3 1 0.567 2 0.6628797000000001 3 0.603369548985357 4 0.6461497881249225 5 0.6173286464638088 This sample run is very very short, because a longer run would take up too much space on a page. You can check your program by using the values above, but see below for more information about demonstrating your program Program requirements Prompt the user to enter the initial population. You must make sure that the user enters a floating point number between O and 1 (inclusive). If they do not enter a value in the correct range, print a message informing them so, and prompt them to enter the value again. Keep doing this until they enter an acceptable value Prompt the user to enter the number of time steps to run. You must make sure that the integer that the user entered is positive. As above, if the entered value is not in the correct range, your program should repeat the request until the user enters an acceptable value. You may assume the user wil enter a number, you don't have to check that it is a number

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!