forked from fenyx-it-academy/Class7-Python-Module-Week4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrectangle.py
More file actions
25 lines (20 loc) · 808 Bytes
/
rectangle.py
File metadata and controls
25 lines (20 loc) · 808 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
# Python program to create Rectangle class
class Rectangle:
#define constructor with attributes: lenght and width
def __init__(self, length, width):
self.length = length
self.width = width
#create perimeter() method
def Perimeter(self):
return 2*(self.length + self.width)
#create Area() method
def Area(self):
return self.length * self.width
#create display() method
def display(self):
print('The length of rectangle is :', self.length)
print("The width of rectangle is: ", self.width)
print("The perimeter of rectangle is: ", self.Perimeter())
print("The area of rectangle is: ", self.Area())
my_rectangle = Rectangle(length=int(input('Length: ')), width=int(input('Width: ')))
my_rectangle.display()