Calculate Simple and Compound Interest
#The User Input is taken using input() function which takes input as a string
#We need the input to be a float
#We did the type conversion using float() function
#The Principal Amount is stored in the variable p
p=float(input("Enter the Principle Amount : "))
#The Number of Years is stored in the variable n
n=float(input("Enter the Number of Years : "))
#The Rate of Interest is stored in the variable r
r=float(input("Enter the Rate of Interest : "))
#Calculate Simple Interest value is stored in the variable s
s=(p*n*r)/100
#Calculate Compound Interest value is stored in the variable c
c=p*(pow((1+(r/100)),n))
#Display Output
#'\n' represent Next Line
print('\n'"Simple Interest")
print("----------------")
print("Principal Amount is ",p)
print("Number of Years is ",n)
print("Rate of Interest is ",r)
print('\n'"Simple Interest Value is ",s)
print("**********************************"'\n')
print("Compound Interest")
print("------------------")
print("Principal Amount is",p)
print("Number of Years is",n)
print("Rate of Interest is",r)
print('\n'"Compound Interest Value is",c)
print("**********************************")
Output:-
Enter the Principle Amount : 1000
Enter the Number of Years : 2
Enter the Rate of Interest : 12.5
Simple Interest
----------------
Principal Amount is 1000.0
Number of Years is 2.0
Rate of Interest is 12.5
Simple Interest Value is 250.0
**********************************
Compound Interest
------------------
Principal Amount is 1000.0
Number of Years is 2.0
Rate of Interest is 12.5
Compound Interest Value is 1265.625
**********************************
Comments