Python Program Input the Radius of Circle and Compute the Area

Python program to input radius of a circle and calculate area of a circle; Through this tutorial, i am going to show you how to write python program which accepts the radius of a circle from the user and compute or find the area of circle.

In this tutorial, i will write a python program to find area of a circle based on user input radius of circle.

Python – Input the Radius of Circle and Compute the Area

  • Write a program to input radius of a circle and calculate its area in python

Program to input radius of a circle and calculate its area in python

Use the following steps and write a program to input radius of a circle and calculate its area in python:

  • Import math module in python program.
  • Get input number from user.
  • Calculate area of the circle with a given radius by using formula pi * r**2.
  • Print result.
# import math module
from math import pi
# take input from user
r = float(input ("Input the radius of the circle : "))
# compute the area from radius of a circle given by user
calculateArea = str(pi * r**2);
#print result
print ("The area of the circle with radius " + str(r) + " is: " + calculateArea)

After executing the program, the output will be:

Input the radius of the circle :  2
The area of the circle with radius 2.0 is: 12.566370614359172

Recommended Python Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *