Question

In: Computer Science

language: python A local biologist needs a program to predict population growth. The inputs would be:...

language: python

A local biologist needs a program to predict population growth. The inputs would be:

  1. The initial number of organisms, as an int
  2. The rate of growth (a real number greater than 1), as a float
  3. The number of hours it takes to achieve this rate, as an int
  4. A number of hours during which the population grows, as an int

For example, one might start with a population of 500 organisms, a growth rate of 2, and a growth period to achieve this rate of 6 hours. Assuming that none of the organisms die, this would imply that this population would double in size every 6 hours. Thus, after allowing 6 hours for growth, we would have 1000 organisms, and after 12 hours, we would have 2000 organisms.

Write a program that takes these inputs and displays a prediction of the total population.

An example of the program input and output is shown below:

Enter the initial number of organisms: 10
Enter the rate of growth [a real number > 1]: 2
Enter the number of hours to achieve the rate of growth: 2
Enter the total hours of growth: 6

The total population is 80

also make sure it test for these cases

Test Case 1

Test for 100 organisms with growth rate of 5 over 2 hrs over 25 hrs total

Test Case 2

Test for 10 organisms with growth rate of 2 over 2 hrs over 6 hrs total

Test Case 3

Test for 0 organisms with growth rate of 5 over 1 hr over 6 hrs total

Test Case 4

Test for 7 organisms with growth rate of 7 over 7 hrs over 7 hrs total

Solutions

Expert Solution

code:

output :

raw_code :

#taking inputs
initial = int(input('Enter the initial number of organisms : '))
rate = float(input('Enter the rate of growth[a real number >1] :'))
hours = int(input('Enter the number of hours to achieve the rate of growth :'))
total = int(input('Enter the total hours of growth :'))

population = initial


#calculating population growth
for i in range(hours,total+1,hours):
population *= rate

#prinint output
print('The total population is ',population)

**do comment for queries and rate me up*****


Related Solutions

language: python A local biologist needs a program to predict population growth. The inputs would be:...
language: python A local biologist needs a program to predict population growth. The inputs would be: The initial number of organisms, as an int The rate of growth (a real number greater than 1), as a float The number of hours it takes to achieve this rate, as an int A number of hours during which the population grows, as an int For example, one might start with a population of 500 organisms, a growth rate of 2, and a...
A local biologist needs a program to predict population growth. The inputs would be: The initial...
A local biologist needs a program to predict population growth. The inputs would be: The initial number of organisms, as an int The rate of growth (a real number greater than 1), as a float The number of hours it takes to achieve this rate, as an int A number of hours during which the population grows, as an int For example, one might start with a population of 500 organisms, a growth rate of 2, and a growth period...
A local biologist needs a program to predict population growth. The inputs would be: The initial...
A local biologist needs a program to predict population growth. The inputs would be: The initial number of organisms The rate of growth (a real number greater than 1) The number of hours it takes to achieve this rate A number of hours during which the population grows For example, one might start with a population of 500 organisms, a growth rate of 2, and a growth period to achieve this rate of 6 hours. Assuming that none of the...
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
Using Python. Write a program that reads a sequence (unknown number of inputs) of integer inputs...
Using Python. Write a program that reads a sequence (unknown number of inputs) of integer inputs and prints the number of even and odd inputs in the sequence. please explain. Thanks
4.9: Population Write a program that will predict the size of a population of organisms. The...
4.9: Population Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number of organisms, their average daily population increase (as a percentage, expressed as a fraction in decimal form: for example 0.052 would mean a 5.2% increase each day), and the number of days they will multiply. A loop should display the size of the population for each day. Prompts, Output Labels and Messages.The three input data...
python program You are going to write a program that takes two inputs: A string representing...
python program You are going to write a program that takes two inputs: A string representing a list of names of the following form: first name 1, last name 1, (nick name 1); first name 2, last name 2, (nick name 2); ... A string representing part of or the complete family name. You are going to output all nick names for those names where there is a partial or complete match of the family name. If no match was...
Write a program in Python language which will do the following: Write a program to prompt...
Write a program in Python language which will do the following: Write a program to prompt the user to enter a company name, city, state and zip code. Create a dictionary with the data. Output the dictionary. Then remove the city from the dictionary and output again.
write a python program that inputs 10 integer values from the keyboard and then displays their...
write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop
Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers...
Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers from the user until they enter a 0 and computes the product of all these numbers and outputs it. Hint: use the example from the slides where we compute the sum of a list of numbers, but initialize the variable holding the product to 1 instead of 0. print("Enter n") n = int(input()) min = n while n != 0: if n < min:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT