calculate compound interest
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.
Related Python Lab Programs
๐
Python Basics
1.
Use a web browser to go to Python website http://python.org. Start Python interpreter and type help().
View Solution โ
3.
Write a Python program to calculate compound interest for given principal amount, rate of interest and number of periods.
Current
4.
Write a Python program to read name, address, email and phone number through keyboard and print them.
View Solution โ
6.
Write a Python program to check whether the given input is a digit, lowercase letter, uppercase letter or special character.
View Solution โ
7.
Write a Python program to print all prime numbers in a given interval using break.
View Solution โ
๐
Arrays, Lists and Tuples
4.
Write a Python function is_sorted() to check whether the elements of a list are sorted.
View Solution โ
5.
Write a Python function has_duplicates() to check whether a list contains duplicate elements.
View Solution โ
6.
Write a Python function remove_duplicates() to remove duplicate elements from a list.
View Solution โ
๐ค
Strings and Dictionaries
1.
Write a Python program to add single-letter words such as I, a and an empty string to a given word list.
View Solution โ
3.
Write a Python program to add a comma between every character of a string. Example: Apple โ A,p,p,l,e.
View Solution โ
4.
Write a Python program to remove a given word from all occurrences in a string.
View Solution โ
5.
Write a Python function to capitalize the first letter of each word in a sentence and convert the remaining letters to lowercase without built-in functions.
View Solution โ
๐
Recursion and Matrices
1.
Write a recursive Python function to generate all binary strings of n-bit length.
View Solution โ
โ๏ธ
Modules, Exceptions and Classes
1.
Create a Python module and demonstrate its use with geometric shapes and operations.
View Solution โ
3.
Define draw_rectangle(Canvas, Rectangle) and write a Python program to draw a rectangle.
View Solution โ
4.
Add a color attribute to the Rectangle class and modify draw_rectangle() to draw a colored rectangle.
View Solution โ
6.
Create a Circle class and write a Python program with draw_circle() to draw a circle.
View Solution โ
๐
Validation and File Handling
1.
Write a Python program to read phone number and email address and validate them.
View Solution โ
3.
Write a Python program to open a file, check whether specified words are present and display the words when found.
View Solution โ
4.
Write a Python program to read a text file and find the word with the most number of occurrences.
View Solution โ
5.
Write a Python program to find the number of words, vowels, blank spaces, lowercase letters and uppercase letters in a text file.
View Solution โ
๐
Python Libraries, Logic Gates and GUI
3.
Write a Python program to implement Digital Logic Gates: AND, OR, NOT and EX-OR.
View Solution โ
4.
Create a GUI window wizard with two text labels, two text fields, Submit and Reset buttons.
View Solution โ