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

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...
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...
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
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the...
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the...
Write a Python program, phone.py, that inputs a string of characters which represent a vanity telephone...
Write a Python program, phone.py, that inputs a string of characters which represent a vanity telephone number, e.g., 800-MYPYTHON, and prints the all numeric equivalent, 800-69798466. You should implement this using a loop construct to process each character from left to right. Build a new string that is the all numeric equivalent and then print the string.
In python. Write a program that takes 2 string inputs and calculates the Hamming Distance. Hamming...
In python. Write a program that takes 2 string inputs and calculates the Hamming Distance. Hamming distance between two strings is the number of positions at which the corresponding symbols are different. The program should output an integer representing this distance. For example a = XXWWZZ b = ZZWWXX answer = 4 More examples: "Phone" and "PHOONE" = 3 "God" and "Dog" = 2 "Dog" and "House" = 4
Write a program in python language, which accepts 2 numbers and a + sign (for addition)...
Write a program in python language, which accepts 2 numbers and a + sign (for addition) A sign - (for subtraction) A sign * (for multiplication), / (for division) Then calculate and to display the result of the operation he chose with the two numbers. Displaying the appropriate message
Write a C++ program that inputs the world's population at the end of last year. Assume...
Write a C++ program that inputs the world's population at the end of last year. Assume population is growing at a rate of 1.12%. Output the year (starting with this year) and the population until the population is greater than 10billion. Test data: 6.83 billion. (leave like this rather than 6800000000). Name as a comment and printed to output. Output as a comment at the bottom of the code
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT