To calculate the area of a circle in Python, here’s the code:

from math import pi def area(r): return pi * r ** 2

You can call this function by giving it the radius of the circle, for example:

print(area(10))

Output:

314.159....

## How to Calculate the Area of a Circle in Maths

To calculate the area of the circle given the radius of the circle, use the following equation.

Sometimes you also have to calculate the area given the **diameter** or the **circumference** of the circle.

Without deriving these simple equations, here are all three formulas to calculate the area given:

**Radius****Diameter****Circumference**

When you implement a Python program do the job using one of these formulas depending on what you want to accomplish with the program.

## Program 1: Circle Area Given Radius

The area of a circle given the radius follows this formula:

To convert this formula to a Python program, you need to:

**Create**a function.**Perform**the calculation given the above formula.**Return**the result.

Here is the implementation for calculating the area of a circle given the circumference:

from math import pi def area(r): return pi * r ** 2

## Program 2: Circle Area Given Diameter

The area of a circle given the diameter follows this formula:

To convert this formula to a Python program, you need to:

**Create**a function.**Perform**the calculation given the above formula.**Return**the result.

Here is the implementation for calculating the area of a circle given the circumference:

from math import pi def area(d): return (pi / 4) * d ** 2

## Program 3: Circle Area Given Circumference

The area of a circle given the circumference follows this formula:

To convert this formula to a Python program, you need to:

**Create**a function.**Perform**the calculation given the above formula.**Return**the result.

Here is the implementation for calculating the area of a circle given the circumference:

from math import pi def area(c): return (c ** 2) / (4 * pi)

## Further Reading

#### About the Author

- I'm an entrepreneur and a blogger from Finland. My goal is to make coding and tech easier for you with comprehensive guides and reviews.

##### Recent Posts

- Artificial Intelligence2023.03.14Best AI Tools of 2023 (Save Time & Boost Productivity)
- Python2023.02.16How to Pass a Variable from HTML Page to Another (w/ JavaScript)
- JavaScript2023.02.16JavaScript How to Get Selected Text from a Textbox
- JavaScript2023.02.15JavaScript Select All Text in Div with a Mouse Click