Python program to find area of circle

As we know how find the circle area mathmatically because in this programing tutorial we are going to use simple maths formula of circle area.

Area = 3.14*Radius*Radius

It means we have to take one parameter from the user to find the area of a circle and that parameter is the radius.

Area-Of-Circle

 

Method-01

Using Function and math library.

import math
def findArea(r):
    areaOfCircle = math.pi* pow(r,2)
    return areaOfCircle

radius = float(input("Enter Radius: ")) area = findArea(radius) print("Area Of Circle: ",area)

Output:

Enter Radius: 2
Area
Of Circle: 12.566370614359172

 

Method-02

Using simple python and maths expression.

radius = float (input ("Enter Radius: "))  
area = 3.14 * radius * radius  
print (" Area Of Circle: ", area)  

Output:

Enter Radius: 2
Area
Of Circle: 12.566370614359172

 

Method-03

Using simple python and direct area formula.

radius = float (input ("Enter Radius: "))  
print (" Area Of Circle: ", 3.14 * (radius**2))  

Output:

Enter Radius: 2
Area
Of Circle: 12.566370614359172

 

Method-04

Using class and object concept.

class circleArea:
    def __init__(self, radius):
        self.radius = radius
    def area(self):
        return 3.14 * (self.radius ** 2)
        
r = float (input ("Enter Radius: ")) 
circle1 = circleArea(r)
print("Area of circle:",circle1.area())

Output:

Enter Radius: 2
Area
Of Circle: 12.566370614359172

 

Leave a comment