Calculating the area of circle using Python

How to find area of circle using python ?

Here, in this page we will discuss the progrm to find area of circle using python .Area of circle is the number of square units inside the circle , can be calculated using the radius and diameter.The formula for evaluating the area of circle is

  • Area of circle using radius=   Pi*r*r    ( r is the radius of circle)
  • Area of circle using diameter=  1/4*Pi*d*d   ( d is the diameter of circle)

Pi is a Greek letter and the value of Pi is equal to 3.14159265359. In the program we will be initiating Pi as global variable or we can simply import from math module present in python.Syntax for importing pi from math module : from math import pi

Area of circle using python

Algorithm

1.Input radius/diameter

2.Calculate area of circle using formula

             area= pi*r*r(if radius is given as input)

             area=(pi*d*d)/4 (if diameter is given as input)

3.Print area

Area of circle

PYTHON CODE

from math import pi

r=float(input("Enter radius of circle :"))

area=pi*r*r

print("The area of circle is",end=" ")

print(area)

Output :

Enter radius of circle : 7

The area of circle is 153.86
from math import pi

d=float(input("Enter diameter of circle :"))

area=(pi*d*d)/4

print("The area of circle is",end="")

print(area)
Output :

Enter diameter of circle : 14

The area of circle is 153.86