Python Programs | IT Developer
IT Developer

Python Programs



Share with a Friend

Python Programs - Conditional Statements

Simple interest or compound interest calculator with user choice - Python Program

Computer Interest

 

A = P(1 + R/100)

Compound Interest = A - P 

Where: 

  • A is amount 
  • P is the principal amount 
  • R is the rate and 
  • T is the time span

 

Simple interest

Simple Interest = (P x T x R)/100

Where:

  • P is the Principal amount
  • T is the Time period (in years)
  • R is the Rate of interest per annum

Example 1 :

choice = input("Simple or Compound (S/C): ").lower() p = float(input("Principal: ")) r = float(input("Rate: ")) t = float(input("Time: ")) if choice == 's': si = (p * r * t) / 100 print("Simple Interest:", si) elif choice == 'c': ci = p * ((1 + r / 100) ** t) - p print("Compound Interest:", round(ci, 2)) else: print("Invalid choice")

Output

 
OUTPUT 1 :
Simple or Compound (S/C): S
Principal: 10000
Rate: 10
Time: 5
Simple Interest: 5000.0
 
OUTPUT 2 :
Simple or Compound (S/C): C
Principal: 10000
Rate: 10
Time: 5
Compound Interest: 6105.1