Initial project costs
The numpy.npv(rate, values)
function is very powerful because it allows you to pass in both positive and negative values.
For this exercise, you will calculate the net present value of two potential projects with different cash flows:
Year | Project 1 | Project 2 |
---|---|---|
1 | -$250 (initial investment) | -$250 (initial investment) |
2 | $100 cash flow | $300 cash flow |
3 | $200 cash flow | -$250 (net investment) |
4 | $300 cash flow | $300 cash flow |
5 | $400 cash flow | $300 cash flow |
In this example, project 1 only requires an initial investment of $250, generating a slowly increasing series of cash flows over the next 4 years.
Project 2, on the other hand, requires an initial investment of $250 and an additional investment of $250 in year 3. However, project 2 continues to generate larger cash flows.
Assuming both projects don't generate any more cash flows after the fifth year, which project would you decide to undertake? The best way to decide is by comparing the NPV of both projects.
Cet exercice fait partie du cours
Introduction to Financial Concepts in Python
Instructions
- Create a
numpy
array of the cash flow values for project 1, assigning it tocash_flows_1
, and then do the same for project 2, assigning the values tocash_flows_2
. - Calculate the net present value of both projects 1 and 2 assuming a 3% inflation rate.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
import numpy as np
# Create an array of cash flows for project 1
cash_flows_1 = np.array(____)
# Create an array of cash flows for project 2
cash_flows_2 = np.array(____)
# Calculate the net present value of project 1
investment_1 = np.npv(rate=____, values=____)
print("The net present value of Investment 1 is worth $" + str(round(investment_1, 2)) + " in today's dollars")
# Calculate the net present value of project 2
investment_2 = np.npv(rate=____, values=____)
print("The net present value of Investment 2 is worth $" + str(round(investment_2, 2)) + " in today's dollars")