View on GitHub

marymafa.github.io

population growth

This exercise was challenging and i made sure that i do it until i get accurate results.

Instructions:

1.At the begging of a year population was 1000. 2.Populaion increased by 2% per year. 3.Moreover 50 new inhabbit per year come to live in the town. 4.HOw many years does the town neded to see its population greater or equal to p=1200.

Problem started :

When i was trying to create a variable that will calculate the population of the begging of the year , increased by 2% per year,50 new habitant per year come to live a town , Like instead of returning years it was returning number of inhabitants and i kept on trying until i get accurate results.

Solution

I have created a function called population growth with three variables for totalyearneeded which is unknown, startofpopulution which is 1000 and the targetpopulation which is 1200. And also, created another variables for calculatingpopulationfor year multiplying by startofpopulation on each year. I created another function that will calculate population for year with variable called previousyearpopulation, and another variable called population calculated which will calculate the previos year population adding by previous year population multiplying by percentage rate which is 0.02 and also adding new habitants which is 50.

On this exerccise i have learned that it is good to understand what i’m doing , So tha t i won’t struggle that much .