import math
class Circle:
def __init__(self, radius):
self.__radius = radius #
def get_area(self):
return math.pi * self.__radius ** 2
def get_perimeter(self):
return 2 * math.pi * self.__radius
# getter method for radius attribute
def get_radius(self):
return self.__radius
# setter method for radius attribute
def set_radius(self, radius):
if not isinstance(radius, int):
print("Error: ", radius, "is not an int")
return
self.__radius = radius
c1 = Circle(5.4)
c2 = Circle(10.5)
def print_circle_info(circle_obj):
print("#########################")
print("Radius of circle", format(circle_obj.get_radius(), "0.2f"))
print("Perimeter of circle", format(circle_obj.get_perimeter(), "0.2f"))
print("Area of circle", format(circle_obj.get_area(), "0.2f"))
print("#########################", end="\n\n")
print_circle_info(c1) # passing circle object c1 to print_circle_info()
print_circle_info(c2) # passing circle object c2 to print_circle_info()