๐Ÿ
B.TECH I YEAR โ€ข II SEMESTER โ€ข R25

Python Programming - Lab Manual

Python Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š II Semester ๐Ÿ Python Programming ๐Ÿงช Lab Program
Selected Program

calculate compound interest

โ† All Python Programs

Aim:

☛   Write a program to calculate compound interest when principal, rate and number of periods are given.

Solution :


The formula to calculate compound interest annually is given by:
    A = P ( 1 + R / 100 )t
    Compound Interest = A - P

Where,
   A is amount,
   P is the principal amount
   R is the rate of interest,
   T is the time span


PROGRAM: (CI.py)

 
# Python program to compute compound interest 
p = int(input(" Enter the principal amount : ")) 
t = float(input(" Enter the time in years : " )) 
r = float(input(" Enter the rate of interest : ")) 
# compute compound interest 
amount = p * (pow((1 + r / 100), t)) 
ci = amount - p 
# print 
print(" Compound Interest : " , ci )

OUTPUT:

 
 Enter the principal amount : 50000
 Enter the time in years : 3.8
 Enter the rate of interest : 2
 Compound Interest :  3907.6819031304913


๐Ÿ’ป Run This Python Program

calculate compound interest
The selected Python program is loaded automatically into the editor. Edit the program, provide input if required and click Run.

The compiler is embedded using OneCompiler. Your Python program runs inside the embedded Python environment; Study Glance does not execute Python code directly on your web server.
โ† Back to Python Lab Programs ๐Ÿ“š All Lab Manuals