calculate perimeter of rectangle in a class in python

Solutions on MaxInterview for calculate perimeter of rectangle in a class in python by the best coders in the world

showing results for - "calculate perimeter of rectangle in a class in python"
Alessio
08 Jun 2020
1class Rectangle:
2    def __init__(self, width, length):
3        self.length = length
4        self.width = width
5        
6    
7    def calculate_perimeter(self):
8        
9        return 2 * (self.width + self.length)
10    
11Rectangle_1 = Rectangle(3, 4)
12
13print (Rectangle_1.calculate_perimeter())