Python Program to Calculate Compound Interest

In this example, we will write a program that calculates the compound interest in Python. To better understand this example, make sure you have knowledge of the following tutorials:- Let us have a look at the formula for calculating the compound interest.

A = P(1 + R/100)T
Where,
A is the amount of money accumulated after n years, including interest.
P is the principal amount
R is the rate and
T is the time span

## Python Program to Calculate Compound Interest

The output of the above program is:-

Enter the principal amount: 100000
Enter the interest rate: 12
Enter the time in years: 5
Compound amount is 176234.17
Compound interest is 76234.17
In this program, the user input is taken using input() function which takes input as a string. But as we are doing the calculation part, we need the input to be a float. So, we did the type-conversion using float() function.
The input from the user is taken as p for the principal amount, t for the time in years and r for the interest rate. The function is defined with def keyword that takes three arguments,  principal, rate and time. The formula is applied and result is returned to the calling function and the output is displayed using print() function. #### Related Article

destination source:https://www.programming-techniques.com/?p=1782

```