Skip to content

Commit 9b383a3

Browse files
committed
Second_Commit
1 parent 60824e6 commit 9b383a3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

compound_interest.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@
1111

1212
# Output:
1313
# compound interest = p * (1 + r/100)^t
14-
14+
import sys
1515

1616
def compound_interest(p, t, r):
1717
return p * (pow((1 + r / 100), t))
1818

1919
def main():
20-
p = float(input("Enter the principal amount: "))
21-
t = float(input("Enter the time period: "))
22-
r = float(input("Enter the rate of interest: "))
2320

24-
print("The compound interest is {:.2f}".format(compound_interest(p, t, r)))
21+
# for speed
22+
read = sys.stdin.readline
23+
write = sys.stdout.write
24+
25+
write("Enter the principal amount: ")
26+
p = float(read())
27+
write("Enter the time period: ")
28+
t = float(read())
29+
write("Enter the interest rate: ")
30+
r = float(read())
31+
32+
print(f"The compound interest is {compound_interest(p, t, r):.2f}")
2533

2634

2735
if __name__ == "__main__":

0 commit comments

Comments
 (0)