Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python (while loops): In this homework you will use a while loop to accumulate a result to simulate the process of growth over time and

Python (while loops): In this homework you will use a while loop to accumulate a result to simulate the process of growth over time and plot it via the turtle.

defaults for the simulation parameters, may later be overwritten by user input

num_years = 200 # number of years we want to to simulate (int) N_start = 1000 # number of organisms we had last year (int) rate = 0.02 # growth factor (multiply with 100 to get % increase per year, so 0.02 means 2% growth) (float) """ Problem 1

Get input from the user for the number of years, number of organisms last year, and the growth factor.

Check the values the user gives you: the number of years to simulate must between 10 and 1000, the starting population must be between 10 to 100000 and the grow rate must be bigger than 0.0 and smaller than 0.2

When you detect values outside these ranges print("value must be to ") and have the user re-enter it. I suggest you wrap each user input into a while loop that is only left when the value is OK.

Optionally, Support lazy users. Make it so that pressing Enter only keeps the default values, input() returns an empty string "" when no value has been entered (but the enter key was pressed).

Obtain the values from the user and check the user input and loop until it is valid

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

Students also viewed these Databases questions