# How to get Python Compound Interest Calculator to give the correct answer?

## How to get Python Compound Interest Calculator to give the correct answer?

If you are entering interest in percentages, you should take care of that in your code.

```
final = P * (((1 + (r/(100.0 * n))) ** (n*t)))
```

Based on this:

Compound Interest Formula

FV = P (1 + r / n)^Yn,

where P is the starting principal, r is the annual interest rate, Y is the number of years invested, and n is the number of compounding periods per year. FV is the future value, meaning the amount the principal grows to after Y years.

```
P = int(input(Enter starting principle please. ))
n = int(input(Enter number of compounding periods per year. ))
r = float(input(Enter annual interest rate. e.g. 15 for 15% ))
y = int(input(Enter the amount of years. ))
FV = P * (((1 + ((r/100.0)/n)) ** (n*y)))
print (The final amount after, y, years is, FV)
```

#### How to get Python Compound Interest Calculator to give the correct answer?

```
# name
NAME=raw_input(Enter Name= )
# Principle amount
P =float(input(Enter Principle Amount: ))
# Rate of interest
R = float(input(Enter rate of Interest: ))
#No Of years
T = float(input(Enter No of Years= ))
#compound interest calculation
CI = P * ( 1 + R / 100)**T
printcompound interest is {:.2f}.format(CI)
```