Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Cyborg-Model-Z/29f561e9aaac6cfc8c9cb4daea662253 to your computer and use it in GitHub Desktop.

Select an option

Save Cyborg-Model-Z/29f561e9aaac6cfc8c9cb4daea662253 to your computer and use it in GitHub Desktop.
Growth of a population
https://www.codewars.com/kata/growth-of-a-population/train/python
>In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants?
So far I got
'''
def nb_year(p0,percent,aug,p):
n=0
while p <= 1200:
p = round(p+p*percent) + aug
n += 1
return(n)
nb_year(1000,.02,50,1000)
@camsbury any idea why this is erroring out?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment