- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

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

When it is required to find the area and perimeter of a circle using classes, object oriented method is used. Here, a class is defined, and attributes are defined. Functions are defined within the class that perform certain operations. An instance of the class is created, and the functions are used to find the area and perimeter of the circle.

Below is a demonstration for the same −

## Example

import math class circle_compute(): def __init__(self,my_radius): self.radius=my_radius def area_calculate(self): return math.pi*(self.radius**2) def perimeter_calculate(self): return 2*math.pi*self.radius my_result = int(input("Enter the radius of circle...")) my_instance = circle_compute(my_result) print("The radius entered is :") print(my_result) print("The computed area of circle is ") print(round(my_instance.area_calculate(),2)) print("The computed perimeter of circle is :") print(round(my_instance.perimeter_calculate(),2))

## Output

Enter the radius of circle...7 The radius entered is : 7 The computed area of circle is 153.94 The computed perimeter of circle is : 43.98

## Explanation

- A class named ‘circle_compute’ class is defined, that has functions like ‘area_calculate’, ‘perimeter_calculate’.
- These are used to calculate the area and perimeter of a circle respectively.
- An instance of this class is created.
- The value for radius is entered and operations are performed on it.
- Relevant messages and output is displayed on the console.

- Related Articles
- Golang Program to Create a Class and Compute the Area and Perimeter of a Circle
- How to compute the area and perimeter of an image contour using OpenCV Python?
- How to calculate the area and perimeter of a circle in JavaScript?
- If the perimeter and the area of a circle are numerically equal, then find the radius of the circle.
- Python Program to find the area of a circle
- Program to find the Area and Perimeter of a Semicircle in C++
- Swift Program to Find the Perimeter of a Circle
- Java Program to Find the Perimeter of a Circle
- Kotlin Program to Find the Perimeter of a Circle
- Explain the perimeter and area of a triangle.
- Program to calculate area and perimeter of Trapezium
- C program to find the area of circle and cylinder using structures.
- Java program to find the area of a circle
- Swift Program to Find the Area of a Circle
- Kotlin Program to Find the Area of a Circle

Advertisements