Python: Compute the future value of a specified principal amount, rate of interest, and a number of years
Python Basic: Exercise-39 with Solution
Write a Python program to compute the future value of a specified principal amount, rate of interest, and a number of years.
The formula for future value with compound interest is FV = P(1 + r/n)^nt.
FV = the future value;
P = the principal;
r = the annual interest rate expressed as a decimal;
n = the number of times interest is paid each year;
t = time in years.
Test Data : amt = 10000, int = 3.5, years = 7
Expected Output : 12722.79
amt = 10000 int = 3.5 years = 7 future_value = amt*((1+(0.01*int)) ** years) print(round(future_value,2))
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
Unpack variables from iterable:
# One can unpack all iterables (tuples, list etc) >>> a, b, c = 1, 2, 3 >>> a, b, c (1, 2, 3) >>> a, b, c = [1, 2, 3] >>> a, b, c (1, 2, 3)
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework