Python program

Python program

Share

05/02/2021

Python Program to Create a Class and Compute the Area and the Perimeter of the Circle .

import math
class circle():
def __init__(self,radius):
self.radius=radius
def area(self):
return math.pi*(self.radius**2)
def perimeter(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.perimeter(),2))

OUTPUT:-

Case 1:
Enter radius of circle: 5
Area of circle: 78.54
Perimeter of circle: 31.42

Case 2:
Enter radius of circle: 10
Area of circle: 314.16
Perimeter of circle: 62.83

03/02/2021
Want your school to be the top-listed School/college in Kanpur?
Click here to claim your Sponsored Listing.

Category

Culinary Team

Attire

Telephone

Website

Address


Kanpur
Kanpur