codescracker


python

Python Program to Calculate Area of Circle



« Previous Program Next Program »


Calculate Area of Circle in Python

To calculate area of a circle in python, you have to ask from user to enter radius of circle to calculate and print area of that circle on the output screen as shown in the program given below.

Python Programming Code to Calculate Area of Circle

Following python program ask from user to enter radius of circle to find area of circle:

# Python Program - Calculate Area of Circle

print("Enter 'x' for exit.");
rad = input("Enter radius of circle: ");
if rad == 'x':
    exit();
else:
    radius = float(rad);
    area = 3.14 * radius * radius;
    print("\nArea of Circle = %0.2f" %area);

Here is the sample run of the above Python program shows how to calculate area of a circle:

calculate area of circle python

Above is the initial output after running the program, now you have to supply the radius of that circle whose area you want to calculate and find out. Therefore enter any radius say 7 to find out the area after pressing the enter key as shown here in below sample output:

area of circle python

Below is the same program on python shell:

python calculate area of circle

Program Video with Compile and Run

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »








Tools
Calculator

Quick Links
Signup - Login - Give Online Test