Skip to content

Commit

Permalink
Create calc
Browse files Browse the repository at this point in the history
  • Loading branch information
mokayaj857 authored Dec 9, 2024
1 parent f23c6b4 commit 275836d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions calc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Function to calculate the accumulated amount and compound interest
def calculate_compound_interest(P, r, n, t):
# Calculate accumulated amount
A = P * (1 + r / n) ** (n * t)

# Calculate compound interest
CI = A - P

# Return both accumulated amount and compound interest
return A, CI

# Given values
P = 150000 # Principal amount in Ksh
r = 0.043 # Annual interest rate (4.3%)
n = 4 # Compounding quarterly
t = 6 # Time in years

# Calculate the accumulated amount and compound interest
A, CI = calculate_compound_interest(P, r, n, t)

# Display the results
print(f"The total accumulated amount after {t} years is: Ksh {A:.2f}")
print(f"The total compound interest after {t} years is: Ksh {CI:.2f}")

0 comments on commit 275836d

Please sign in to comment.