Python program to find the area of a circle
Python program to find the area of a circle
This article will discuss how to find the area of a circle in Python with a given radius. The area of a circle represents the number of square units inside the circle. The following is a mathematical formula to calculate the area of a circle:
Area = ?r² Or, Area = 3.14 * r * r
Let us calculate it through several methods.
Method 1: Area of Circle using ? = 3.14
#Take radius as input from user r = int(input("Enter radius: ")) #Mathematical expression for the area of a circle area = 3.14 * r * r #Print result print("The area of circle is %.4f" % area)
Output
Here is the output:

Method 2: Area of Circle by importing math file
#program to find the area of a circle using a math file #import math file import math #Take radius as input from user r = int(input("Enter radius: ")) #Mathematical expression for the area of circle area = math.pi* r * r #print result print("The area of circle is %.4f" %area)
Output
Here is the output:

Method 3: Area of Circle using functions
#program to calculate the area of circle using functions #import math file import math #Function to get area of circle def area_of_circle(r): area = r**2 * math.pi return area #Take radius as input from user r = int(input("Enter radius: ")) #print result print("The area of circle is %.4f" %area_of_circle(r))
Output
Here is the output:

Explanation: In all these programs, a user first asks to enter radius as an input. This input will be stored in a variable "r". Next, the mathematical expression will calculate the circle area and stored their result in a variable area. Finally, the result is displayed on the screen.