Select Page

# Program to calculate the area of circle in Python

by | Jan 14, 2021 | Python Programs

Home » Python » Python Programs » Program to calculate the area of circle in Python

## Introduction

In this article, we are going to understand the python code to calculate the area of circle. To calculate the area of circle we should know the radius or diameter value of circle. Area is calculated by the given formula:

```Area of circle = ∏*r2
Where,
∏ = pi having constant value = 3.14 ## Program

```def area_circle(r):
pi = 3.14
r = float(r)
area = pi*r*r
print("Area of circle of radius {0} is {1}".format(r,area))
area_circle(r)```

Output: ## Explanation

In the above python program, we have created a function area_circle() to calculate the area based on the input radius of circle. The radius is casted into float as the user might enter the float value and also as the pi has constant value 3.14, the arithmetic calculation of integer and float will give error.

## Author

• A Full Stack Developer with 10+ years of experience in technical content creation.

• 