python-scipyHow can I use Python and SciPy to calculate the Present Value of a Perpetuity with Growth?
The Present Value of a Perpetuity with Growth can be calculated using Python and SciPy. The formula for calculating the present value is as follows:
PV = C / (r - g)
Where C is the cash flow, r is the discount rate, and g is the growth rate.
The following example code uses SciPy to calculate the present value of a perpetuity with a cash flow of $1000, a discount rate of 5%, and a growth rate of 3%:
from scipy.finance import pv
cash_flow = 1000
discount_rate = 0.05
growth_rate = 0.03
present_value = pv(discount_rate, growth_rate, cash_flow)
print(present_value)
Output example
14285.714285714287
Code explanation
from scipy.finance import pv
: imports thepv
function from thescipy.finance
module.cash_flow = 1000
: assigns the cash flow to a variable.discount_rate = 0.05
: assigns the discount rate to a variable.growth_rate = 0.03
: assigns the growth rate to a variable.present_value = pv(discount_rate, growth_rate, cash_flow)
: calculates the present value using thepv
function.print(present_value)
: prints the present value.
Helpful links
More of Python Scipy
- How do I create a 2D array of zeros using Python and NumPy?
- How do I use Python Numpy to read and write Excel (.xlsx) files?
- How to use Python, XML-RPC, and NumPy together?
- How do I use Python XlsxWriter to write a NumPy array to an Excel file?
- How can I check if a certain version of Python is compatible with SciPy?
- How do I use the NumPy transpose function in Python?
- How do I use the scipy ttest_ind function in Python?
- How do I convert a Python Numpy array to a list?
- How do I use Python and SciPy to create a tutorial PDF?
- How can I use Python and Numpy to parse XML data?
See more codes...