ㅋㅋㅋ - 1 year ago 72
Python Question

How can I get the loop to display the initial inputs and how to accept percentages '%' as output

The problem is "Write a program that predicts the approximate size of a population of organisms. The application should use text boxes to allow the user to enter the starting number of organisms, the average daily population increase (as a percentage), and the number of days the organisms will be left to multiply. For example, assume the user enters the following values:

Starting number of organisms: 2

Average daily increase: 30%

Number of days to multiply: 10"

This is my code so far:

``````s = int(input("Starting number of organisms: "))
i = float(input("Average daily increase: "))
d = int(input("Number of days to multiply: "))
print("Day Approximate\tPopulation")
for d in range(s, d + 1):
print(d - 1, '\t', s)
``````

Output should look something like this:

``````Day Approximate Population
1               2
2               2.6
3               3.38
4               4.394
5               5.7122
6               7.42586
7               9.653619
8               12.5497
9               16.31462
10              21.209
``````

This is the output from my code, the "Average daily increase" is 0.30 because I'm not sure how to put in percentage and get the code to read it as ~0.X

``````Starting number of organisms: 2
Average daily increase: 0.30
Number of days to multiply: 10
Day Approximate Population
1    2.6
2    3.38
3    4.394
4    5.7122
5    7.42586
6    9.653618
7    12.5497034
8    16.31461442
9    21.208998746000002
``````

thanks.

I am not sure that I understood your question.. maybe this:

``````s = int(input("Starting number of organisms: "))
i = float(input("Average daily increase[%]: "))/100.0
d = int(input("Number of days to multiply: "))
first = True
print("Day Approximate\tPopulation")
for d in range(s, d + 1):
if first:
print(1, '\t', s)
first = False