-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshapes.py
58 lines (43 loc) · 1.57 KB
/
shapes.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
#!/usr/bin/env python3
from triangle import *
from circle import *
from rectangle import*
#Lists where all info about the shapes are saved
triangles =[]
rectangles =[]
circles =[]
def shapes():
import math
while True:
choose = input("Choose a shape (triangle - t, rectangle - r, circle - c). q quits:")
if choose == "q":
break;
if choose in ['triangle','TRIANGLE','Triangle','t']:
base = input("Give base of the triangle:")
height = input("Give height of the triangle:")
area =0.5*float(base)*float(height)
tri= Triangle(base,height,area)
triangles.append(tri)
print("The area is","%.2f" %area)
elif choose in ['rectangle','RECTANGLE','Rectangle','r']:
width = input("Give width of the rectangle:")
height = input("Give height of the rectangle:")
area =float(width)*float(height)
rec= Rectangle(width,height,area)
rectangles.append(rec)
print("The area is","%.2f" %area)
elif choose in ['circle','CIRCLE','Circle','c']:
radius = input("Give radius of the circle:")
area =(float(radius)**2)*3.14159265358979323846
circ= Circle(radius,area)
circles.append(circ)
print("The area is","%.2f" %area)
else:
print("Unknown shape! Try again!")
#Functions for returning shape lists to be used by other functions
def get_tri():
return triangles
def get_rec():
return rectangles
def get_cir():
return circles