Dcoder icon

The Floating circle @ Dcoder

By Lochard | As a newbie programmer | 27 May 2023


Title: The Floating circle

Problem: Cody is a student in Trumph Academy, He is preparing for SSC, while he was solving some problems, he found an easy problem of Circles. The problem is You have to calculate the area of a Circle, radius of the circle is given. He decided to solve it using code, let us help Cody solving the problem.

Input: Input containts a float number,radius of circle r.

Output: Print area of circle.

If the radius is negative or zero then the area would be "0" without quotes.

PS: Take PI=3.14 and answer should be precise to 2 digit after '.' 

Constraints: -1000≤r≤1000

Sample Input: 5

Sample Output: 

78.50

r = float(input())
print(0 if r <= 0 else '{:.2f}'.format(3.14 * r*r))

How do you rate this article?

2


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.