Learnitweb

Python program to find area of circle

In this article, we are going to discuss how to calculate the area of circle in Python with a given radius.

The formula for calculating the area of circle is:

Area of circle = π * r * r

Here value of π (Pi) is 3.1415 (to 4 decimal places) and r is radius of the circle.

Area of circle by using math module

#program to find area of circle in Python using math
import math
r = float(input("Enter the radius of the circle: "))
area = math.pi* r * r
print("Area of the circle is %.6f" %area)

Output

Enter the radius of the circle: 2
Area of the circle is 12.566371

Area of circle using value of pi

#program to find area of circle in Python using value of pi
pi = 3.14
r = float(input("Enter the radius of the circle: "))
area = pi * r * r
print("Area of the circle is %.2f" %area)

Output

Enter the radius of the circle: 2
Area of the circle is 12.56