Write a python program to find the area of a circle using radius, circumstance, and diameter. The area of a circle is the number of square units inside the circle. The standard formula to calculate the area of a circle is A = πr².

## Python Program to find Area Of Circle using Radius

If we know the radius, then we can calculate the area of a circle using the formula: A=πr² (Here, A is the area of the circle, and r is the radius). In this program, we will find the area of a circle using a radius.

# using Radius PI = 3.14 radius = float(input(' Please Enter the radius of a circle: ')) area = PI * radius * radius circumference = 2 * PI * radius print(" Area Of a Circle = %.2f" %area) print(" Circumference Of a Circle = %.2f" %circumference)

We defined pi as a global variable and assigned the value as 3.14. This python program allows users to enter the value of a radius. And then, it will calculate the area of a circle as per the formula. The output of the example is

```
Please Enter the radius of a circle: 6
Area Of a Circle = 113.04
Circumference Of a Circle = 37.68
```

## Python Program to find Area Of Circle using Circumference

Distance around the circle is called the circumference. If you know the circumference, then we can calculate the area of a circle using the formula: A= C²⁄ 4π (Here, C is circumference)

import math circumference = float(input(' Please Enter the Circumference of a circle: ')) area = (circumference * circumference)/(4 * math.pi) print(" Area Of a Circle = %.2f" %area)

Area of a circle using circumference output

```
Please Enter the Circumference of a circle: 26
Area Of a Circle = 53.79
```

First, We imported the math library, which supports us in using all the mathematical functions in Python programming. In this Python example, we can call the PI value using math.pi

import math

The next line of the python program allows the user to enter the value of a circumference.

circumference = float(input(' Please Enter the Circumference of a circle: '))

Using the circumference, this program will calculate the area of a circle as per the formula: A= C²⁄ 4π.

## Python Program to Calculate Area Of a Circle using Diameter

The distance across the circle passing through the center is called the diameter. If we know the diameter, then we can calculate the area of a circle using the formula: A=π/4*D² (D is the diameter)

import math diameter = float(input(' Please Enter the Diameter of a circle: ')) area1 = (math.pi/4) * (diameter * diameter) # diameter = 2 * radius # radius = diameter/2 radius = diameter / 2 area2 = math.pi * radius * radius print(" Area of Circle using direct formula = %.2f" %area1); print(" Area of Circle Using Method 2 = %.2f" %area2)

This program allows the user to enter the diameter value. Next, it will calculate the area of a circle as per the formula shown above.

We also mentioned another approach.

diameter = 2 * radius

radius = diameter/2

area = π * radius * radius

Comments are closed.