top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Program to calculate NPV

Writer's picture: Amr Mohamed SalamaAmr Mohamed Salama
  • Net present value, or NPV, is used to calculate the current total value of a future stream of payments.

  • If the NPV of a project or investment is positive, it means that the discounted present value of all future cash flows related to that project or investment will be positive, and therefore attractive.

  • To calculate NPV, you need to estimate future cash flows for each period and determine the correct discount rate.




where:

Rt = Net cash inflow/outflows during a single period

ti = Discount rate/return that could be earned in alternative investments

t = Number of timer periods


Calculating NPV with Python


let us consider project (X) with following specifications:


life time = 15 years

initail investments = 2000000 $

final project value = 1000000 $

project_cash_flow = [ - 2000000, 0 , 0 , 250000, 250000, 500000, 500000, 750000, 750000, 500000, 500000, 500000, 500000, 500000, 1000000]

discount_rate = [0.05, 0.055, 0.06, 0.065, 0.07, 0.075, 0.08, 0.085, 0.09, 0.095, 0.1, 0.105, 0.11, 0.115, 0.12, 0.125, 0.13, 0.135, 0.14, 0.145, 0.15]


we decide to perform a Net Present Value (NPV) analysis to determine the profitability of the project



Importing the python packages
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt​

Input Data

project_cash_flow= [-2000000, 0, 0, 250000, 250000, 500000, 500000, 750000, 750000, 500000, 500000, 500000, 500000, 500000, 1000000]

discount_rate = [0.05, 0.055, 0.06, 0.065, 0.07, 0.075, 0.08, 0.085, 0.09, 0.095, 0.1, 0.105, 0.11, 0.115, 0.12, 0.125, 0.13, 0.135, 0.14, 0.145, 0.15]

Function to calculate NPV


def calculate_npv(rate, cash_flow):
    npv = 0
    for t in range(len(cash_flow)):
        npv += cash_flow[t]/(1+rate)**t
    return npv

npvs_a = list()
for rate in discount_rate:
  npv_a = calculate_npv(rate,project_a)
  npvs_a.append(npv_a)

Graphical Representation

plt.plot(discount_rate,npvs_a, linewidth = 3.0, color = "green", label = "Project X")
plt.axhline(y=0, linewidth = 0.5, color = "black")
plt.title('NPV Profile: Project X')
plt.xlabel('Discount Rate')
plt.ylabel('Net Present Value')
plt.legend()
plt.show()

Output Graph






0 comments

Recent Posts

See All

Comments


COURSES, PROGRAMS & CERTIFICATIONS

 

Advanced Business Analytics Specialization

Applied Data Science with Python (University of Michigan)

Data Analyst Professional Certificate (IBM)

Data Science Professional Certificate (IBM)

Data Science Specialization (John Hopkins University)

Data Science with Python Certification Training 

Data Scientist Career Path

Data Scientist Nano Degree Program

Data Scientist Program

Deep Learning Specialization

Machine Learning Course (Andrew Ng @ Stanford)

Machine Learning, Data Science and Deep Learning

Machine Learning Specialization (University of Washington)

Master Python for Data Science

Mathematics for Machine Learning (Imperial College London)

Programming with Python

Python for Everybody Specialization (University of Michigan)

Python Machine Learning Certification Training

Reinforcement Learning Specialization (University of Alberta)

Join our mailing list

Data Insight participates in affiliate programs and may sometimes get a commission through purchases made through our links without any additional cost to our visitors.

bottom of page