Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Rectangle:
- def __init__(self,x,y):
- self.x=x
- self.y=y
- def __str__(self):
- s= "Length = " + str(self.x) + " Width = " +str(self.y)
- return s
- def area(self):
- A=self.x*self.y
- return A
- def perimeter(self):
- P=2*self.x + 2*self.y
- return P
- R1=Rectangle(4,5)
- print R1.area()
- print R1.perimeter()
- print R1
- R1=Rectangle(16,7)
- print R1.area()
- print R1.perimeter()
- print R1
- x = int(input("Enter the value of x"))
- y = int(input("Enter the value of y"))
- R1=Rectangle(x,y)
- print R1.area()
- print R1.perimeter()
- print R1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement