import math
def simple_interest(principal, rate, time):
return (principal * rate * time) / 100
def compound_interest(principal, rate, time):
return principal * (pow((1 + rate/100), time)) - principal
def loan_emi(principal, rate, time):
monthly_rate = rate / (12 * 100)
months = time * 12
emi = (principal * monthly_rate * pow(1 + monthly_rate, months)) / (pow(1 +
monthly_rate, months) - 1)
return emi
def savings_growth(principal, monthly_deposit, rate, time):
months = time * 12
balance = principal
monthly_rate = rate / (12 * 100)
for _ in range(months):
balance = (balance + monthly_deposit) * (1 + monthly_rate)
return balance
def percentage_calculator():
print("\n===== Percentage Calculator =====")
print("1. P% of X")
print("2. A is what percent of B")
print("3. Percentage increase")
print("4. Percentage decrease")
print("5. Marks percentage")
choice = input("Select option (1–5): ")
if choice == '1':
P = float(input("Enter percentage (P): "))
X = float(input("Enter number (X): "))
return (P / 100) * X
elif choice == '2':
A = float(input("Enter A: "))
B = float(input("Enter B: "))
return (A / B) * 100
elif choice == '3':
original = float(input("Enter original value: "))
new = float(input("Enter new value: "))
return ((new - original) / original) * 100
elif choice == '4':
original = float(input("Enter original value: "))
new = float(input("Enter new value: "))
return ((original - new) / original) * 100
elif choice == '5':
marks = float(input("Enter marks obtained: "))
total = float(input("Enter total marks: "))
return (marks / total) * 100
else:
print("Invalid choice.")
return None
def profit_loss_calculator():
CP = float(input("Enter Cost Price (CP): "))
SP = float(input("Enter Selling Price (SP): "))
if SP > CP:
profit = SP - CP
profit_percent = (profit / CP) * 100
print("Profit =", profit)
return profit_percent
elif CP > SP:
loss = CP - SP
loss_percent = (loss / CP) * 100
print("Loss =", loss)
return loss_percent
else:
print("No profit, no loss.")
return 0
while True:
print("\n===== Finance Calculator =====")
print("1. Simple Interest")
print("2. Compound Interest")
print("3. Percentage Calculator")
print("4. Profit / Loss Calculator")
print("5. Exit")
choice = input("Enter your choice (1–5): ")
if choice == '1':
p = float(input("Enter Principal: "))
r = float(input("Enter Rate of Interest (%): "))
t = float(input("Enter Time (years): "))
si = simple_interest(p, r, t)
print("Simple Interest =", si)
elif choice == '2':
p = float(input("Enter Principal: "))
r = float(input("Enter Rate of Interest (%): "))
t = float(input("Enter Time (years): "))
ci = compound_interest(p, r, t)
print("Compound Interest =", ci)
elif choice == '3':
result = percentage_calculator()
if result is not None:
print("Result =", result, "%")
elif choice == '4':
result = profit_loss_calculator()
print("Percentage =", result, "%")
elif choice == '5':
print("Exited. Goodbye!")
break
else:
print("Invalid choice. Please try again.")