
Problem
Solution
Submissions
Calculate the Area of a Circle
Certification: Basic Level
Accuracy: 60.57%
Submissions: 279
Points: 5
Write a Python program that calculates the area of a circle given its radius.
Example 1
- Input: 5
- Output: 78.53981633974483
- Explanation:
- Step 1: Apply the formula for circle area: A = π × r².
- Step 2: A = 3.141592653589793 × 5² = 3.141592653589793 × 25 = 78.53981633974483.
- Step 3: Return 78.53981633974483 as the result.
Example 2
- Input: 2.5
- Output: 19.634954084936208
- Explanation:
- Step 1: Apply the formula for circle area: A = π × r².
- Step 2: A = 3.141592653589793 × 2.5² = 3.141592653589793 × 6.25 = 19.634954084936208.
- Step 3: Return 19.634954084936208 as the result.
Constraints
- 0 < radius ≤ 10^6
- Use π = 3.141592653589793 for calculations
- Time Complexity: O(1)
- Space Complexity: O(1)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Use the formula: area = π * r^2
- Import math module: import math; area = math.pi * radius ** 2
- Define π as a constant: PI = 3.141592653589793; area = PI * radius * radius
- Use lambda function: area_calc = lambda r: math.pi * r * r