-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsquare_rect.py
More file actions
25 lines (23 loc) · 812 Bytes
/
square_rect.py
File metadata and controls
25 lines (23 loc) · 812 Bytes
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
class Shape:
def area(self, shape, length, width):
if shape == "square":
return length * length
elif shape == "rectangle":
return length * width
else:
return "Invalid shape"
class Area(Shape):
def takevalue(self):
self.shape = input("square or rectangle:- ").lower()
if self.shape == "square":
self.length = float(input("Enter length:- "))
return self.area(self.shape, self.length, 0)
elif self.shape == "rectangle":
self.length = float(input("Enter length:- "))
self.width = float(input("Enter width:- "))
return self.area(self.shape, self.length, self.width)
else:
print("Invalid Input")
hi = Area()
a = hi.takevalue()
print("AREA:", a)