Question
A positive quantity (e.g. an investment or a population) grows at a constant rate of rate percent every year. Write a function doubling_time which takes
A positive quantity (e.g. an investment or a population) grows at a constant rate of rate percent every year. Write a function doubling_time which takes as input a positive floating point number rate and which returns the least non-negative integer k such that the initial quantity will have (at least) doubled after k years. For example doubling_time(100) should be 1 because at an annual growth rate of 100%, the initial size will have doubled after precisely one year. On the other hand, doubling_time(50) should be 2 since the initial population will have grown to 150% of its initial size after one year, and then to 225% of its initial size after a total of two years. If rate is less than or equal to 0, then your function should execute the statement
raise ValueError
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started