Created
June 17, 2019 23:59
-
-
Save Cyborg-Model-Z/29f561e9aaac6cfc8c9cb4daea662253 to your computer and use it in GitHub Desktop.
Growth of a population
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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