-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfutval_graph4.py
More file actions
37 lines (29 loc) · 1.09 KB
/
futval_graph4.py
File metadata and controls
37 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# futval_graph4.py
from graphics import *
def createLabeledWindow():
window = GraphWin("Investment Growth Chart", 320, 240)
window.setBackground("white")
window.setCoords(-1.75,-200, 11.5, 10400)
Text(Point(-1, 0), ' 0.0K').draw(window)
Text(Point(-1, 2500), ' 2.5K').draw(window)
Text(Point(-1, 5000), ' 5.0K').draw(window)
Text(Point(-1, 7500), ' 7.5k').draw(window)
Text(Point(-1, 10000), '10.0K').draw(window)
return window
def drawBar(window, year, height):
bar = Rectangle(Point(year, 0), Point(year+1, height))
bar.setFill("green")
bar.setWidth(2)
bar.draw(window)
def main():
print("This program plots the growth of a 10 year investment.")
principal = float(input("Enter the initial principal: "))
apr = float(input("Enter the annualized interest rate: "))
win = createLabeledWindow()
drawBar(win, 0, principal)
for year in range(1, 11):
principal = principal * (1 + apr)
drawBar(win, year, principal)
input("Press <Enter> to quit.")
win.close()
main()