Sunday, 23 January 2022

Python 20A-Write a python program to create a class Circle and Compute the Area and the circumferences of the circle.(use parameterized constructor)

 Write a python program to create a class Circle and Compute the Area and the circumferences of the circle.(use parameterized constructor)    

import math

class circle():

    def __init__(self,radius):

        self.radius=radius

    def area(self):

        return math.pi*(self.radius**2)

    def circumferences(self):

        return 2*math.pi*self.radius

 

r=int(input("Enter radius of circle: "))

obj=circle(r)

print("Area of circle:",round(obj.area(),2))

print("Perimeter of circle:",round(obj.circumferences(),2))