File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1111
1212# Output:
1313# compound interest = p * (1 + r/100)^t
14-
14+ import sys
1515
1616def compound_interest (p , t , r ):
1717 return p * (pow ((1 + r / 100 ), t ))
1818
1919def 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
2735if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments