Computer Science, asked by scsays, 1 year ago

write a python program that accepts radius of a circle and prints it's area.

Answers

Answered by QGP
99

Area of a Circle is givem by:


\sf Area = \pi\times radius^2


So we have to take an input of the value of radius, compute the value of area and print it accordingly.


We need the value of \pi too. We can set its value as 22/7 or 3.1416 approximately.


Or we can use the pi available in the math module.


Here is a sample program which accomplishes the task:


#Program to calculate Area of Circle


from math import pi


#Or we can set pi=3.1416 approximately


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


area=pi*radius*radius


print("Area of the circle is",format(area,'.3f'),"sq units")


The format command with '.3f' rounds off the value of area to three decimal places.


A screenshot of the code along with its execution at the terminal is attached.

Attachments:
Answered by sourasghotekar123
0

We know that, area of a circle is calculated as,

A=\pi r^{2}

Algorithm

Step 1: Begin.

Step 2: Take input radius, r from user.

Step 3: Calculate area of circle using above formula.

Step 4: Print Area

Step 5: End.

Python program that takes a circle's radius and prints its area

from math import pi

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

print ("The area of the circle with radius " + str(r) + " is: " + str(pi * r**2))

#SPJ2

Similar questions