Commit ff588901 authored by logesh.n's avatar logesh.n

area of the square using decorator

parent bc68f637
""" Finding the area and side of a square """
class Square:
def __init__(self, side):
self._side = side
@property
def side(self):
return self._side
@side.setter
def side(self, value):
if value >= 0:
self._side = value
else:
print("error")
@property
def area(self):
return self._side ** 2
@classmethod
def unit_square(cls):
return cls(1)
side = int(input("Enter the side of the square = "))
s = Square(side)
print("Side of the square = ", s.side)
print("Area of the square = ", s.area)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment