Python Practice › OOP Programs › Program 26

Circle area and circumference

EasyOOP Programs · 26 of 48

Create a Circle class with a radius and methods for area and circumference.

Advertisement
Output
153.94 43.98

Approach

  1. Use math.pi.

Solution

Python
import math class Circle:    def __init__(self, radius):        self.radius = radius     def area(self):        return round(math.pi * self.radius ** 2, 2)     def circumference(self):        return round(2 * math.pi * self.radius, 2) c = Circle(7)print(c.area(), c.circumference())
Output
153.94 43.98

Learn the concept

New to this topic? Read the lesson, then come back.

More oop programs

← All 48 OOP Programs

Leave a Comment