Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

calculate perimeter of rectangle in a class in python

class Rectangle:
    def __init__(self, width, length):
        self.length = length
        self.width = width
        
    
    def calculate_perimeter(self):
        
        return 2 * (self.width + self.length)
    
Rectangle_1 = Rectangle(3, 4)

print (Rectangle_1.calculate_perimeter())
Comment

PREVIOUS NEXT
Code Example
Python :: numpy savetxt list of strings 
Python :: wav file to array python 
Python :: change password django 
Python :: python lists 
Python :: legend for pie chart matplotlib 
Python :: max of a list python 
Python :: count number items in list python 
Python :: ordenar lista python 
Python :: train dev test split sklearn 
Python :: line plotly with shaded area 
Python :: perform_update serializer django 
Python :: check for string in list pytho 
Python :: make a new environment conda 
Python :: start python server 
Python :: sum of prime numbers python 
Python :: map function in python 
Python :: Python NumPy ndarray flatten Function Example 
Python :: numpy loadtxt skip header 
Python :: combine list of dicts 
Python :: how to strip white space of text in python? 
Python :: python read file xlsx and return a list 
Python :: open file dialog on button click pyqt5 
Python :: append multiple values to 2d list python 
Python :: python access each group 
Python :: Modify a Python interpreter 
Python :: how to count the lines of code using open in python 
Python :: empty list in python 
Python :: remove all elements from list python by value 
Python :: python escape character example 
Python :: for each loop python 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =