-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f23c6b4
commit 275836d
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |