Get Started

Future value

The numpy module also contains a similar function, .fv(rate, nper, pmt, pv), which allows you to calculate the future value of an investment as before with a few simple parameters:

  • rate: The rate of return of the investment
  • nper: The lifespan of the investment
  • pmt: The (fixed) payment at the beginning or end of each period (which is 0 in our example)
  • pv: The present value of the investment

It is important to note that in this function call, you must pass a negative value into the pv parameter if it represents a negative cash flow (cash going out). In other words, if you were to compute the future value of an investment, requiring an up-front cash payment, you would need to pass a negative value to the pv parameter in the .fv() function.

This is a part of the course

“Introduction to Financial Concepts in Python”

View Course

Exercise instructions

  • Using NumPy's .fv() function, calculate the future value of a $10,000 investment returning 5% per year for 15 years and assign it to investment_1.
  • Calculate the future value of a $10,000 investment returning 8% per year for 15 years and assign it to investment_2.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

import numpy as np

# Calculate investment_1
investment_1 = ____(rate=____, nper=____, pmt=0, pv=____)
print("Investment 1 will yield a total of $" + str(round(investment_1, 2)) + " in 15 years")

# Calculate investment_2
investment_2 = ____
print("Investment 2 will yield a total of $" + str(round(investment_2, 2)) + " in 15 years")

This exercise is part of the course

Introduction to Financial Concepts in Python

BeginnerSkill Level
4.6+
8 reviews

Using Python and NumPy, learn the most fundamental financial concepts.

Learn about fundamental financial concepts like the time value of money, growth and rate of return, discount factors, depreciation, and inflation.

Exercise 1: Fundamental financial conceptsExercise 2: Growth and rate of returnExercise 3: Compound interestExercise 4: Discount factors and depreciationExercise 5: Present and future valueExercise 6: Present valueExercise 7: Future value
Exercise 8: Adjusting future values for inflationExercise 9: Net present value and cash flowsExercise 10: Discounting cash flowsExercise 11: Initial project costsExercise 12: Diminishing cash flows

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free