Python program to find the circumference of a circle

Python program to find the circumference of a circle :

In this tutorial, we will learn how to find the circumference of a circle in python 3. The formulae to calculate circumference is ‘2 * Pi * radius’. So, we need only the value of radius to calculate the circumference. We will take this input from the user. Let’s take a look :

Python program :

import math

radius = float(input("Enter radius of the circle : "))

circumference = 2 * math.pi * radius

print("Circumference of the circle is : %.2f" % circumference)

Example Output :

Enter radius of the circle : 5
Circumference of the circle is : 31.42

Enter radius of the circle : 10
Circumference of the circle is : 62.83

Enter radius of the circle : 0
Circumference of the circle is : 0.00

Enter radius of the circle : 1200
Circumference of the circle is : 7539.82

Enter radius of the circle : 12.5
Circumference of the circle is : 78.54

Explanation :

1. First take the radius input from the user. The radius is a floating value. So, we are using ‘float(input())‘.
2. Calculate the circumference. The value of Pi is taking from ‘math‘ module of python. ‘math.pi‘ gives the value of pi.
3. Print the value of the circumference. The value is formatted up to two decimal places using %.2f .

Sitewide-USD 336x280

Leave a Reply