We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 40d7b4b commit 50d8d34Copy full SHA for 50d8d34
compound_interest.py
@@ -0,0 +1,24 @@
1
+# This script calculates yearly compound interest given principal, annual rate of interest and time period in years.
2
+# Do not use this in production. Sample purpose only.
3
+
4
+# Author: Upkar Lidder (IBM)
5
6
+# Input:
7
+# p, principal amount
8
+# t, time period in years
9
+# r, annual rate of interest
10
11
+# Output:
12
+# compound interest = p * (1 + r/100)^t
13
14
15
+def compound_interest(p, t, r):
16
+ return p * (pow((1 + r / 100), t))
17
18
19
+if __name__ == "__main__":
20
+ p = float(input("Enter the principle amount: "))
21
+ t = float(input("Enter the time period: "))
22
+ r = float(input("Enter the rate of interest: "))
23
24
+ print("The compound interest is {:.2f}".format(compound_interest(p, t, r)))
0 commit comments