[7 kyu] Growth of a Population
Question
Sample Tests
My Answer (accepted)
def nb_year(p0, percent, aug, p):
final_people_num = 0
year = 0
real_percent = percent / 100
while final_people_num < p:
year += 1
p0 = p0 * (1 + real_percent) + aug
final_people_num = p0
print(final_people_num)
return year
Suggested Answer
def nb_year(population, percent, aug, target):
year = 0
while population < target:
population += population * percent / 100. + aug
year += 1
return year