Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# 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 principal 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)))

Loading