Create a class circles having members radius. Use operator overloading to add the radius of two circle objects. Also display the area of circle.
import
math
class
Circle:
def __init__(self, radius):
self.__radius = radius
def setRadius(self, radius):
self.__radius = radius
def getRadius(self):
return self.__radius
def area(self):
return math.pi * self.__radius ** 2
def __add__(self, another_circle):
return Circle( self.__radius +
another_circle.__radius )
c1 =
Circle(4)
print(c1.getRadius())
c2 =
Circle(5)
print(c2.getRadius())
c3 =
c1 + c2 # overloaded + operator by adding a
method named __add__
print(c3.getRadius())