-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompound.py
More file actions
24 lines (17 loc) · 873 Bytes
/
compound.py
File metadata and controls
24 lines (17 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#-------------------------------------------------------------
# Quinn Olney 9/6/24 Compound Interest Function
#------------------------------------------------------------
import stdio
import math
import sys
#collecting the variables from command line input for the equation
#y = p * e^(t*r), t represents time passed, r is the rate of compounding and p is the principal
t = int(sys.argv[1])
p = int(sys.argv[2])
r = float(sys.argv[3])
#here we're using the math.exp method which takes e^x or the input in the parenthesis, and then we multiply it by
#the principal, after that I use the round method which takes two arguments (x,y) x= the number to be rounded
#and y what decimal place it rounds to
result = round(p * (math.exp(r*t)), 2)
#finally we output it to the command line using the standard io library
stdio.writeln('Your total would be ' + str(result))