Python Program to Calculate Area of Circle


Way 1 – Area of Circle Using user-defined pi

In [1]:
radius = float(input("Please Enter Radius : "))
pi = 3.142

area = pi*(radius**2)

print("Area of circle =", area)
Please Enter Radius : 12
Area of circle = 452.448

Here, we are asking users to enter radius and defined pi as 3.142. Then the area of the circle is calculated using the formula pi*r*r.

Way 2 – Area of Triangle Using Math Module

In [1]:
import math

radius = float(input("Please Enter Radius : "))
pi = 3.142

area = math.pi*pow(radius, 2)

print("Area of circle =", area)
Please Enter Radius : 7
Area of circle = 153.93804002589985

In this approach, we use the math module to calculate the area of the triangle. We are fetching value of pi using math.pi and using pow() function.


deneme bonusu veren siteler
deneme bonusu