Population growth at a constant annual growth rate of r% is governed by a simple equation: Pn = Pn-1 +r · Pn-1 where Pn is the population in the n-th year, and Pn-1 is the population in the previous year. Here r is a number between 0.0 and 1.0 representing a percentage (e.g. 0.3 = 30%). You can see that to get the new population you simply add r% of the previous population to the previous population to obtain the new population for the next year. The above formula assumes that population can grow forever with no restrictions. In reality, population growth is restricted by available resources such as food or energy. If the environment can only support a maximum population of K, then the growth rate r in the equation above has to be further multiplied by (1 – P(n-1)/K). With this added to the model, the population growth will slow as the population approaches K. Write a recursive function that takes four parameters: • The initial population in year 1. • The year n for which we want to compute the population. • The annual growth rate r (a floating point value between 0.0 and 1.0, e.g. 0.2 means 20%). • The maximum population K that the environment can support. and returns the population in year n. To verify that your program works, test your function with r = 0.01 (i.e. 8% growth rate), K=10000, and an initial population of 900. Using these parameters, compute the population for years 1 through 100. Create and display a line plot using matplotlib of the population over time. Finally, use your function to solve the following problem: For initial population of 7 billion, an annual growth rate of 1.1%, and a maximum population of 1O billion, determine how many years it will take until the pop- ulation exceeds 9.9 billion. Print your answer to the console.
Population growth at a constant annual growth rate of r% is governed by a simple equation: Pn = Pn-1 +r · Pn-1 where Pn is the population in the n-th year, and Pn-1 is the population in the previous year. Here r is a number between 0.0 and 1.0 representing a percentage (e.g. 0.3 = 30%). You can see that to get the new population you simply add r% of the previous population to the previous population to obtain the new population for the next year. The above formula assumes that population can grow forever with no restrictions. In reality, population growth is restricted by available resources such as food or energy. If the environment can only support a maximum population of K, then the growth rate r in the equation above has to be further multiplied by (1 – P(n-1)/K). With this added to the model, the population growth will slow as the population approaches K. Write a recursive function that takes four parameters: • The initial population in year 1. • The year n for which we want to compute the population. • The annual growth rate r (a floating point value between 0.0 and 1.0, e.g. 0.2 means 20%). • The maximum population K that the environment can support. and returns the population in year n. To verify that your program works, test your function with r = 0.01 (i.e. 8% growth rate), K=10000, and an initial population of 900. Using these parameters, compute the population for years 1 through 100. Create and display a line plot using matplotlib of the population over time. Finally, use your function to solve the following problem: For initial population of 7 billion, an annual growth rate of 1.1%, and a maximum population of 1O billion, determine how many years it will take until the pop- ulation exceeds 9.9 billion. Print your answer to the console.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Python 3
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education