-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpenditureChart.py
More file actions
133 lines (114 loc) · 2.85 KB
/
expenditureChart.py
File metadata and controls
133 lines (114 loc) · 2.85 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#The purpose of this exercise is to create a column chart based on the user's entered values.
#Besides creating the columns, the program also highlights the value that has the largest value.
from turtle import*
bob= Turtle()
scr=bob.getscreen()
rent= int(scr.numinput("How much for rent?","How much will you spend on rent?"))
utilities= int(scr.numinput("How much for utilities?","How much will you spend on utilities?"))
food= int(scr.numinput("How much for food?", "How much will you spend on food?"))
fun= int(scr.numinput("How much for fun?", "How much will you spend on fun?"))
bob.penup()
bob.goto(-100,0)
bob.setheading(0)
bob.pendown()
#rent bar
if rent>utilities and rent>food and rent>fun:
bob.color("black","red")
else:
bob.color("black","blue")
bob.begin_fill()
for i in range(2):
bob.forward(30)
bob.left(90)
bob.forward(rent/3)
bob.left(90)
bob.end_fill()
val_rent=str(rent)
bob.penup()
bob.goto(-100, rent/3+5)
bob.setheading(0)
bob.write("$"+val_rent,font=("Calibri",12,"normal"))
bob.penup()
bob.goto(-100,-20)
bob.setheading(0)
bob.write("Rent",font=("Calibri",12,"normal"))
bob.penup()
bob.goto(-50,0)
bob.setheading(0)
bob.pendown()
#utilities bar
if utilities>rent and utilities>food and utilities>fun:
bob.color("black","red")
else:
bob.color("black","blue")
bob.begin_fill()
for i in range(2):
bob.forward(30)
bob.left(90)
bob.forward(utilities/3)
bob.left(90)
bob.end_fill()
val_utilities=str(utilities)
bob.penup()
bob.goto(-50, utilities/3+5)
bob.setheading(0)
bob.write("$"+val_utilities,font=("Calibri",12,"normal"))
bob.penup()
bob.goto(-50,-20)
bob.setheading(0)
bob.write("Utilities",font=("Calibri",12,"normal"))
bob.penup()
bob.goto(0,0)
bob.setheading(0)
bob.pendown()
#food bar
if food>utilities and food>rent and food>fun:
bob.color("black","red")
else:
bob.color("black","blue")
bob.begin_fill()
for i in range(2):
bob.forward(30)
bob.left(90)
bob.forward(food/3)
bob.left(90)
bob.end_fill()
val_food=str(food)
bob.penup()
bob.goto(0, food/3+5)
bob.setheading(0)
bob.write("$"+val_food,font=("Calibri",12,"normal"))
bob.penup()
bob.goto(0,-20)
bob.setheading(0)
bob.write("Food",font=("Calibri",12,"normal"))
bob.penup()
bob.goto(50,0)
bob.setheading(0)
bob.pendown()
#fun bar
if fun>utilities and fun>food and fun>rent:
bob.color("black","red")
else:
bob.color("black","blue")
bob.begin_fill()
for i in range(2):
bob.forward(30)
bob.left(90)
bob.forward(fun/3)
bob.left(90)
bob.end_fill()
val_fun=str(fun)
bob.penup()
bob.goto(50, fun/3+5)
bob.setheading(0)
bob.write("$"+val_fun,font=("Calibri",12,"normal"))
bob.penup()
bob.goto(50,-20)
bob.setheading(0)
bob.write("Fun",font=("Calibri",12,"normal"))
#title
title_height= max(rent,utilities,fun,food)/3
bob.penup()
bob.goto(-70,title_height+30)
bob.write("Monthly Expenses", font=("Times new roman",14,"bold"))