Learn Programming and technology with ease @ developerpublish.com

HomePythonPython Program to Find the Area and Perimeter of a Circle using Class

# Python Program to Find the Area and Perimeter of a Circle using Class

Object-oriented programming (OOP) allows us to create classes that encapsulate data and methods. This program demonstrates how to create a Python program that calculates the area and perimeter of a circle using a class.

## Problem Statement

Write a Python program that defines a class for a circle, calculates its area and perimeter, and provides methods to access these values.

## Python Program to Find the Area and Perimeter of a Circle using Class

```import math

class Circle:

def calculate_area(self):
return math.pi * self.radius ** 2

def calculate_perimeter(self):
return 2 * math.pi * self.radius

# Input

# Creating a Circle object

# Calculating area and perimeter
area = circle.calculate_area()
perimeter = circle.calculate_perimeter()

# Output
print("Area:", area)
print("Perimeter:", perimeter)```

### You May Also Like

#### Python Program to Remove Duplicates from a Linked List

In this Python program, we will create a singly linked list and remove duplicate elements from it. A linked list...

#### Python Program to Solve the Celebrity Problem

This Python program solves the Celebrity Problem by finding a person who is known by everyone but does not know...

#### Python Program to Solve n-Queen Problem with Recursion

This Python program uses a recursive approach to solve the n-Queens problem. It explores all possible combinations of queen placements...