COMPUTE AREA OF CIRCLE FROM RADIUS IN PYTHON

COMPUTE AREA OF CIRCLE FROM RADIUS IN PYTHON

Describe the issue:

Create a function that uses the circle’s radius as a parameter to compute and return the area of a circle.

The area should be rounded to two decimal places. The round() function is available.

Note 2: Round to 3.14159.

Note3:

You merely need to use the function given; you don’t need to accept any input on this issue.

Format for Input

The number of test cases is stated in the first line. There will be one line of input per test case:
Each testcase’s radius is inputted in integer format on a new line.
Format for Output

Each testcase’s area in float format, rounded to the nearest two decimal places.
Typical Input

Sample Output: 1 5

78.54
Sample justification

Circles with radii of 5 cm have an area of 3.14159 x (5 x 5) = 78.53975 cm2.

Rounding by two numbers results in 78.54 cm2.

Approach:

def aoc(r):
    a = 3.14 * (r * r)
    return round(a,2)

print(aoc(5))

Leave a Reply

%d bloggers like this: