Exercise 1

Write a Circle class.

Requirements:

  • An instance of the Circle class should take $x$ and $y$ coordinates of the circle.
  • You must include the initializer constructor (__init__).
  • Include methods to compute the radius, area, and circumference of the circle
  • Demo your Circle class

In [23]:
class Circle():
    
    def __init__(self,x,y):
        self.x=x
        self.y=y
        
    def radius(self):
        import math
        return(math.sqrt(self.x**2+self.y**2))
       
    def area(self):
        return(self.x**2+self.y**2)*3.14
    def circumference(self):
        import math
        return(math.sqrt(self.x**2+self.y**2)*2*3.14)

In [30]:
r=Circle(3,4).radius
print(Circle(3,4).radius())
print(Circle(3,4).area())
print(Circle(3,4).circumference())


5.0
78.5
31.400000000000002

In [ ]:


In [ ]: