Python 3 Script to Find Area of Circle Using Math Module and Functions Full Tutorial For Beginners

You are currently viewing Python 3 Script to Find Area of Circle Using Math Module and Functions Full Tutorial For Beginners

 

Welcome folks today in this post we will be calculating area of circle in python script using math module. All the full source code of the application will be given below.

 

 

Get Started

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

app.py

 

 

#program to find area of circle using functions
import math

#Function that calculates area of circle
def area_of_circle(r): 
    a = r**2 * math.pi
    return a

r = float(input("Enter the radius of the circle: "))
print("%.2f" %area_of_circle(r))

 

 

As you can see we are importing the built in math module of python to calculate area of circle by the standard formula. Now to run this python script you need to provide the radius of the circle as shown below

 

python app.py

 

 

 

Leave a Reply