-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllArea.py
191 lines (191 loc) · 6.91 KB
/
AllArea.py
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#edit the pi if you need it more or less digits
pi = 3.1415
class Area:
def rectangle(self):
width = float(raw_input("What is the width?:"))
height = float(raw_input("What is the height?:"))
result = height*width
print ("Formula: width * height")
print ("Result/Answer: " + str(result))
def square(self):
side = float(raw_input("What is the length?:"))
result = side** 2
print ("Formula: side^2")
print ("Result/Answer: " + str(result))
def triangle(self):
width = float(raw_input("What is the width?:"))
height = float(raw_input("What is the height?:"))
result = width*height/2
print ("Formula: width * height / 2")
print ("Result/Answer: " + str(result))
def circle(self):
radius = float(raw_input("What is the radius?:"))
result = radius** 2 *pi
print ("Formula: radius^2 * pi")
print ("Result/Answer: " + str(result))
def trapezoid(self):
base1 = float(raw_input("What is base 1?:"))
base2 = float(raw_input("What is base 2?:"))
height = float(raw_input("What is the height?:"))
result = height/2 * (base1+base2)
print ("Formula: height * .5 * (base1 + base2)")
print ("Result/Answer: " + str(result))
def pentagon(self):
apothem = float(raw_input("What is the apothem?:"))
side = float(raw_input("What is the length of a side?:"))
result = (side*5) *apothem /2
print ("Formula: (side*5) * apothem /2")
print ("Result/Answer: " + str(result))
def hexagon(self):
side = float(raw_input("What is the side length?:"))
height = float(raw_input("What is the height?:"))
result = 1.5*height*side
print ("Formula: 1.5 * height * side")
print ("Result/Answer: " + str(result))
def recprism(self):
height = float(raw_input("What is the height?:"))
width = float(raw_input("What is the width?:"))
length = float(raw_input("What is the length?:"))
result = 2*height*width+2*height*length+2*width*length
print ("Formula: 2*height*width + 2*height*length + 2*width*length")
print ("Result/Answer: " + str(result))
def sphere(self):
radius = float(raw_input("What is the radius?:"))
result = 4 * pi * radius**2
print ("Formula: 4 * pi *radius^2")
print ("Result/Answer: " + str(result))
def cone(self):
slant = float(raw_input("What is the slant length?:"))
radius = float(raw_input("What is the radius?:"))
result = pi*radius**2 + pi*slant
print ("Formula: pi*radius^2 + pi*slant")
print ("Result/Answer: " + str(result))
def cylinder(self):
radius = float(raw_input("What is the radius?:"))
height = float(raw_input("What is the height?:"))
result = 2*pi*radius*height + 2*pi*radius**2
print ("Formula: 2*pi*radius*height + 2*pi*radius*radius")
print ("Result/Answer: " + str(result))
def ellipse(self):
minor = float(raw_input("What is half of the minor axis?:"))
major = float(raw_input("What is half of the major axis?:"))
result = minor*major*pi
print ("Formula: minor * major * pi")
print ("Result/Answer: " + str(result))
def triprism(self):
print ("Equalateral, Isosceles, Scalene")
triangle = raw_input("What type?:")
if triangle == "equalateral":
allArea.etrip();
elif triangle == "isosceles":
allArea.itrip();
elif triangle == "scalene":
allArea.strip();
else:
allArea.nshape();
def etrip(self):
height = float(raw_input("What is the height?:"))
length = float(raw_input("What is the length?:"))
base = float(raw_input("What is the base?:"))
result = base * height + base * length * 3
print ("Formula: base * height + base * length * 3")
print ("Result/Answer: " + str(result))
def itrip(self):
height = float(raw_input("What is the height?:"))
length = float(raw_input("What is the length?:"))
base = float(raw_input("What is the base?:"))
side = float(raw_input("What is the side?:"))
result = base*height+base*length+side*length*2
print ("Formula: base*height + base*length + side*length*2")
print ("Result/Answer: " + str(result))
def strip(self):
height = float(raw_input("What is the height?:"))
length = float(raw_input("What is the length?:"))
side1 = float(raw_input("What is the length of side1?:"))
side2 = float(raw_input("What is the length of side2?:"))
side3 = float(raw_input("What is the length of side3?:"))
result = height*side1+length*side1+length*side2+length*side3
print ("Formula: height*side1+ length*side1+ length*side2+ length*side3")
print ("Result/Answer: " + str(result))
def pyramid(self):
slant = float(raw_input("What is the slant length?:"))
height = float(raw_input("What is the height?:"))
width = float(raw_input("What is the width?:"))
length = float(raw_input("What is the length?:"))
perimeter = width * 2 + length * 2
result = perimeter * .5 * slant
print ("Formula: perimeter * .5 * slant")
print ("Result/Answer: " + str(result))
def cube(self):
length = float(raw_input("What is the length?:"))
result = length**2 * 6
print ("Formula: length^2 * 6")
print ("Result/Answer: " + str(result))
def octagon(self):
side = float(raw_input("What is the length of the side?:"))
result = side**2 * 4.84
print ("Formula: side^2 * 4.84")
print ("Result/Answer: " + str(result))
def decagon(self):
side = float(raw_input("What is the length of the side?:"))
span = float(raw_input("What is the span?:"))
result = 2.5 * side * span
print ("Formula: 2.5 * side * span")
print ("Result/Answer: " + str(result))
def ngon(self):
nsides = float(raw_input("How many sides are there?:"))
side = float(raw_input("What is the length of one side?:"))
apothem = float(raw_input("What is the length of the apothem?:"))
result = (nsides*side) * apothem / 2
print ("Formula: (# of sides*side) *apothem /2")
print ("Result/Answer: " + str(result))
def nshape(self):
print ("Shape not supported!")
shape = raw_input("What type of shape to calculate:")
allArea=Area();
if shape == "rectangle":
allArea.rectangle();
elif shape == "paralellogram":
allArea.rectangle();
elif shape == "square":
allArea.square();
elif shape == "triangle":
allArea.triangle();
elif shape == "circle":
allArea.circle();
elif shape == "trapezoid":
allArea.trapezoid();
elif shape == "pentagon":
allArea.pentagon();
elif shape == "hexagon":
allArea.hexagon();
elif shape == "rectangular prism":
allArea.recprism();
elif shape == "cuboid":
allArea.recprism();
elif shape == "sphere":
allArea.sphere();
elif shape == "cone":
allArea.cone();
elif shape == "cylinder":
allArea.cylinder();
elif shape == "ellipse":
allArea.ellipse();
elif shape == "triangular prism":
allArea.triprism();
elif shape == "pyramid":
allArea.pyramid();
elif shape == "sector":
allArea.sector();
elif shape == "cube":
allArea.cube();
elif shape == "octagon":
allArea.octagon();
elif shape == "decagon":
allArea.decagon();
elif shape == "regular polygon":
allArea.ngon();
elif shape == "ngon":
allArea.ngon();
else:
allArea.nshape();