The area of a circle can simply be evaluated using the following formula.
Area = pi * r2
where r is radius of circle
Python Program to Find Area of a Circle
Python3
def findArea(r):
PI = 3.142
return PI * (r * r);
print ( "Area is %.6f" % findArea( 5 ));
|
Time Complexity: O(1) since no loop is used the algorithm takes up constant time to perform the operations
Auxiliary Space: O(1) since no extra array is used so the space taken by the algorithm is constant
Python Program to Find Area of a Circle With Math library
Python3
import math
def area(r):
area = math.pi * pow (r, 2 )
return print ( 'Area of circle is:' ,area)
area( 4 )
|
OutputArea of circle is: 50.26548245743669
Time Complexity: O(1)
Auxiliary Space: O(1)
Please refer complete article on Program to find area of a circle for more details!