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 thepvfunction from thescipy.financemodule.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 thepvfunction.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 create a zero matrix using Python and Numpy?
- How do I use Scipy zeros in Python?
- How can I use Python Scipy to zoom in on an image?
- How can I use Python and Numpy to parse XML data?
- How do I use Python Numpy to read and write Excel (.xlsx) files?
- How do I use Python Scipy to generate a PDF?
- How do I use Python and SciPy to create a tutorial PDF?
- How can I use Python and Numpy to zip files?
- How do I calculate the cross-correlation of two arrays using Python and NumPy?
See more codes...