Ask Question
30 January, 21:33

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.

+3
Answers (1)
  1. 30 January, 23:18
    0
    import math start_pop = int (input ("Enter start population: ")) daily_increase = float (input ("Daily population increase: ")) num_days = int (input ("Number of day multiplied: ")) pop_size = start_pop for i in range (1, num_days+1) : pop_size + = pop_size * daily_increase print ("Day " + str (i) + ": " + str (math. floor (pop_size)))

    Explanation:

    The solution code is written in Python 3

    Since we wish to round the population size to integer, we need to import math module to use its floor method in a later stage (Line 1)

    Next, prompt user input for start population, daily increase percent and number of day they will multiply (Line 2 - 4)

    Next create a variable pop_size and set the start_pop as initial value

    Create a for loop that run num_days of rounds and within the loop apply the formula to increase the population size based on the daily_increase rate and print it to console (Line 8 - 10).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number of ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers