-
Notifications
You must be signed in to change notification settings - Fork 0
/
exp7-4.py
36 lines (34 loc) · 1019 Bytes
/
exp7-4.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
class Rect:
def __init__(self):
self.leng=0
self.wid=0
def set(self,leng,wid):
if leng>0.0 and leng<20.0:
self.leng=leng
if wid>0.0 and wid<20.0:
self.wid=wid
print("set sucessful")
def get(self):
print("length=",self.leng)
print("width=",self.wid)
def area(self):
return self.leng*self.wid
def peri(self):
return 2*(self.leng+self.wid)
r=Rect()
print("1.enter length and width\n2.show leng and wid\n3.find area\n4.find peri\n5.exit")
n=int(input("enter ur choice"))
while(n!=5):
print("1.enter length and width\n2.show leng and wid\n3.find area\n4.find peri\n5.exit")
n=int(input("enter ur choice"))
if n==1:
l,b=int(input("enter length")),int(input("enter breadth"))
r.set(l,b)
elif n==2:
r.get()
elif n==3:
print("area=",r.area())
elif n==4:
print("perimeter=",r.peri())
else:
break