-
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.
Signed-off-by: Upkar Lidder <[email protected]>
- Loading branch information
Upkar Lidder
committed
Jan 12, 2022
1 parent
40d7b4b
commit 50d8d34
Showing
1 changed file
with
24 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,24 @@ | ||
# This script calculates yearly compound interest given principal, annual rate of interest and time period in years. | ||
# Do not use this in production. Sample purpose only. | ||
|
||
# Author: Upkar Lidder (IBM) | ||
|
||
# Input: | ||
# p, principal amount | ||
# t, time period in years | ||
# r, annual rate of interest | ||
|
||
# Output: | ||
# compound interest = p * (1 + r/100)^t | ||
|
||
|
||
def compound_interest(p, t, r): | ||
return p * (pow((1 + r / 100), t)) | ||
|
||
|
||
if __name__ == "__main__": | ||
p = float(input("Enter the principle amount: ")) | ||
t = float(input("Enter the time period: ")) | ||
r = float(input("Enter the rate of interest: ")) | ||
|
||
print("The compound interest is {:.2f}".format(compound_interest(p, t, r))) |