DEV Community

Discussion on: Daily Challenge #197 - Population Growth

Collapse
 
maskedman99 profile image
Rohit Prasad • Edited

Python

p0 = int(input("Enter the starting population: "))
percent = float(input("Enter the percent: "))
aug = int(input("Enter the no.of inhabitants coming each year: "))
p = int(input("Enter the population to surpass: "))

percent = percent/100
years = 0

while p0 <= p:
        p0 = p0 + percent*p0 + aug
        years += 1

print(years)