-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArea_and_perimeter.py
142 lines (94 loc) · 3.23 KB
/
Area_and_perimeter.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
select = input("Enter the shape name : ")
choose = input("Enter the what you want : ")
class Shape():
def message(self):
return "This feature is not available now. We are developing it."
if select == "rectangle":
def __init__(self , l , b):
if choose == "area":
self.area = l * b
elif choose == "perimeter":
self.perimeter = 2 * (l + b)
else:
print("Invalid")
elif select == "square":
def __init__(self, side):
if choose == "area":
self.area = side ** 2
elif choose == "perimeter":
self.perimeter = 4 * side
else:
print("Invalid")
elif select == "trapezium":
def __init__(self ,h , a , b):
if choose == "area":
self.area = h * ( a + b ) / 2
else:
print("Invalid")
elif select == "rhombus":
def __init__(self, p , q):
if choose == "area":
self.area = p * q / 2
else:
print("Invalid")
elif select == "quadrilateral":
def __init__(self, d , h1 , h2):
if choose == "area":
self.area = d * (h1 + h2) / 2
else:
print("Invalid")
else:
print("This shape is not available")
if select == "rectangle":
length = int(input("Enter the length: "))
wide = int(input("Enter the width: "))
React = Shape(int(length), int(wide))
if choose == "area":
print(React.area)
elif choose == "perimeter":
print(React.perimeter)
else:
print("invalid")
elif select == "square":
side = int(input("Enter the side: "))
Square = Shape(side)
if choose == "area":
print(Square.area)
elif choose == "perimeter":
print(Square.perimeter)
else:
print("invalid")
elif select == "trapezium":
h = int(input("Enter the height: "))
a = int(input("Enter the length of base of trapezium: "))
b = int(input("Enter the length of upper part of trapezium: "))
Trapezium = Shape(h , a, b)
if choose == "area":
print(Trapezium.area)
elif choose == "perimeter":
print(Trapezium.message())
else:
print("invalid")
elif select == "rhombus":
p = int(input("Enter the length of the first diagonal: "))
q = int(input("Enter the length of the second diagonal: "))
rhombus= Shape(p, q)
if choose == "area":
print(rhombus.area)
elif choose == "perimeter":
print(rhombus.message())
else:
print("invalid")
elif select == "quadrilateral":
d = int(input("Enter the length of the diagonal: "))
h1 = int(input("Enter the length of the first height: "))
h2 = int(input("Enter the length of the second height: "))
quadrilateral = Shape(d , h1 , h2)
if choose == "area":
print(quadrilateral.area)
elif choose == "perimeter":
print(quadrilateral.message())
else:
print("invalid")
else:
print("Invalid")