Basic python program to calculate area of circle using function. In this program, we can calculate the area of a circle using a function for beginners to understand and implement the circle function.
Pi Definition in Python
The number is a mathematical constant with a value of around 3.14159. It is defined as the circumference to diameter ratio of a circle in Euclidean geometry, and it has several comparable meanings. The number can be found in a variety of formulas in mathematics and physics.
def() Function in Python
The procedure for defining a function in Python is as follows. The keyword def is used to define a function. The name of the function is followed by the parameter(s) in (). The colon denotes the beginning of the function body, which is denoted by an indentation. The return statement determines the value to be returned inside the function body.
Return Statement in Python
The function call is terminated with a return statement, which “returns” the result the value of the expression following the return keyword to the caller. The statements following the return statements are skipped. If there is no expression in the return statement, the special value None is returned.
Python Program to Calculate Area of Circle Using Function
def func(r): PI = 3.142 return PI * (r*r); print("Area of Circle %.5f" % func(5));
Area of Circle 78.55000