python program to calculate compound interest

python program to calculate compound Interest using function, the input will be principal, the rate of interest and duration of time.

what is Compound interest

Compound interest formula

A= P * (1 + R / 100) t

CI=A-P

where

P  principal

R  Interest

t  Time

A  total amount

CI Compound interest

The logic to find Compound Interest

  1. ask user to input  and store in a variable
  2. principal in a variable P
  3. interest in a variable R
  4. Time  in a variable T
  5. use the formula to find Compound interest
  6. print Compound interest

python program to calculate compound interest

principle=float(input("Enter principle amount:"))
time=int(input("Enter time duration:"))
rate=float(input("Enter rate of interest:"))
amount = (principle * (1 + (float(rate)/100))**time)
compound_interest=amount-principle;
print("Total amount:- ",amount)
print("Compound interest:- ",compound_interest)

 

python program to calculate compound interest using function

principle=float(input("Enter principle amount:"))
time=int(input("Enter time duration:"))
rate=float(input("Enter rate of interest:"))
def cou_interest(principle,time,rate):
    return (principle * (1 + (float(rate) / 100)) ** time)

amount =cou_interest(principle,time,rate)
compound_interest=amount-principle;
print("Total amount:- ",amount)
print("Compound interest:- ",compound_interest)
python program to calculate compound interest
outpot

 

use online IDE to Run and get output Click here


you may also like

C program to calculate simple interest using function

cpp program to calculate simple interest using function c++

Leave a Reply

Your email address will not be published. Required fields are marked *