File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1+ 
2+ # This script calculates yearly compound interest given principal, annual rate of interest and time period in years. 
3+ # Do not use this in production. Sample purpose only. 
4+ 
5+ # Author: Upkar Lidder (IBM) 
6+ 
7+ # Input: 
8+ # p, principal amount 
9+ # t, time period in years 
10+ # r, annual rate of interest 
11+ 
12+ # Output: 
13+ # compound interest = p * (1 + r/100)^t 
14+ 
15+ 
16+ def  compound_interest (p , t , r ):
17+     return  p  *  (pow ((1  +  r  /  100 ), t ))
18+ 
19+ 
20+ if  __name__  ==  "__main__" :
21+     p  =  float (input ("Enter the principal amount: " ))
22+     t  =  float (input ("Enter the time period: " ))
23+     r  =  float (input ("Enter the rate of interest: " ))
24+ 
25+     print ("The compound interest is {:.2f}" .format (compound_interest (p , t , r )))
26+ 
Load Diff This file was deleted. 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments