Write a python programming for calculating compound interest
Answers
Answer:
Python Program to Calculate Compound Interest
def compound_interest(principle, rate, time):
result = principle * (pow((1 + rate / 100), time.
return result.
p = float(input("Enter the principal amount: "))
r = float(input("Enter the interest rate: "))
t = float(input("Enter the time in years: "))
amount = compound_interest(p, r, t)
interest = amount - p.
The following codes must be typed in script mode, saved and then executed.
CODE 1:
p = float(input("Enter the principal amount:"))
r = float(input("Enter the interest rate:"))
n = float(input("Enter the tenure of compoundings:"))
t = float(input("Enter the time period:"))
print("The compound interest is", p*(1 + r/n)**n*t)
OUTPUT:
4000
5
1
2
CODE 2:
p = float(input("Enter the principal amount:"))
r = float(input("Enter the interest rate:"))
n = float(input("Enter the tenure of compoundings:"))
t = float(input("Enter the time period:"))
a = p*(1 + r/n)**n*t
print("The compound interest is", a)
OUTPUT:
4000
5
1
2